This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL SQL TAG

 
Ramkumar Subburaj
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am developing a small e-commerce site and i came accross the jstl sql tag.

As of now i am using tag handler to do all the db operations and process the data to display it in the jsp page.

can i use the jstl sql tag instead of this and is there any disadvantage in this tag.

and when does the connection close if i use this jstl sql tag
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i use the jstl sql tag instead of this and is there any disadvantage in this tag.

Yes, you can, but I would strongly recommend you not to. JSP's role is not to shake hands with a database. You'd better go through a dedicated component (servlet, JSF backing bean...) to retrieve the data.

when does the connection close if i use this jstl sql tag

You should have already been discouraged from using these tags But you can still check the JSTL specification, 10.3 <sql:query> and 10.5 <sql:transaction>.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSTL Specification itself says not to use these tags for any production code.
 
Ramkumar Subburaj
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your reply.

the current method i am using is by calling a custom tag handler which access the db, puts all the data into bean which in turn is put into a array list.

then i am storing the array list in pagecontext and accessing it in the jsp using EL.

Is there any disadvantage in this approach or is there a better way?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic