• Post Reply Bookmark Topic Watch Topic
  • New Topic

is JSTL weak?  RSS feed

 
moneer mohammed
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing some project where i have t display some data to the client in tabular format
And user can select whatever rows he want to delete and he can chose more than one row
But the problem in JSP where I am using JSTL for deleting set of rows
This the code

<c:forEach var="checkboxValue" items="${paramValues.checkboxName}">
<sql:update var="user" dataSource="jdbc/poolDB">
DELETE FROM userInfo
WHERE userId='${ checkboxValue }'
</sql:update>
</c:forEach>

And it is working will.
Now the problem is for deleting one row by using this code it kill the performance,
As for every row I have to get connection and statement after that close them
And agene for new row do same thing agene so to delete set of rows by using one Connection object in this example
Note
I had change the name of the variables for readable purpose
Thanks in advance
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is weak, as it should be.

The point of JSTL was to standardize the tags that every company wanting to write scriptles JSPs, previously had to implement themselves.

When writing scriptless JSPs all the real heavy lifting (especially database CRUD operations) should be done in Java classes that are called from servlets.
After all this heavy lifting is done, context gets passed to the JSP for formatting. When written this way, JSTL is more than sufficient for what most people need.

JSTL SQL tags were never intended to be used in production apps.
Their own specs say they are only there as a convenience for writing prototypes and trivial applications. Many, (myself included) think they were a mistake than never should have been included in the JSTL spec to begin with.

The first paragraph of chapter 10 in the JSTL spec:

Many web applications need to access relational databases as the source of dynamic data for their presentation layer. While it is generally preferred to have database operations handled within the business logic of a web application designed with an MVC architecture, there are situations where page authors require this capability within their JSP pages (e.g. prototyping/testing, small scale/simple applications, lack of developer resources).

[ January 30, 2007: Message edited by: Ben Souther ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a bit off topic for this forum but an operation like that one would really benefit from a PreparedStatement (or a stored procedure, if possible).
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i agreed with ben, according to applying business logic in your java class/Servlet and separate from your presentation layer.

Suggestion:
fill the Array with Selected Check boxes and passing this array to java class/servlet method and perform your deleting process inside.

hope it helps..
 
moneer mohammed
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for your advices
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!