wood burning stoves 2.0*
The moose likes JDBC and the fly likes Returning the ResultSet to the JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Returning the ResultSet to the JSP" Watch "Returning the ResultSet to the JSP" New topic
Author

Returning the ResultSet to the JSP

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi ,

Can this be possible .

When i get the data from the database , it is filled up on to the ResultSet ,and from there on into Collection classes.

Can i put this ResultSet in a scoped attribute and send it to the jsp (Instead of putting the Data on to the Collection class)


Save India From Corruption - Anna Hazare.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18708
    
    8

Sure you can. But there are numerous good reasons not to do that, so you shouldn't.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you paul , but can you please tell me why we should not do that way ??
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18708
    
    8

Mostly because you can't access the methods of the ResultSet in JSTL. You'd have to write scriplets to access it instead. Not to mention that you won't have access to the connection, so it won't be closed properly after you finish using the ResultSet. It's just a bad programming practice to pass ResultSet references around in this way, even within a single program.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Ya , Thank you .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Returning the ResultSet to the JSP