• Post Reply Bookmark Topic Watch Topic
  • New Topic

Send resultset from servlet to jsp

 
anu vinaya
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


I have to send ResultSet from servlet to jsp.Please give an example
using sessions and servletContext.
Which one is better?

Thankyou,
Anuvinaya.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neither is a good idea for a result set.

Binding it to servletContext will keep it around for the life of your application.
Binding it to session will keep it around for the length of your user's session.

Since a resultSet is not really a datastructure and is more of a pipe to your database, binding to anything that will last longer than it takes to read from it is a bad idea. ResultSets are also not serializable so binding one to session can cause other problems in your app.

It's common to pull the data from the resultset, into another data-structure , close the resultset, statement, and connection, and then bind the new data-structure to whatever scope is appropriate for your app.
 
Milan Jagatiya
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
ben is right...

retrive records from ResultSet and put it in the collection and set collection as a property in your bean. access bean in your jsp page.

hope you got.
milan.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!