Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet-jsp communication

 
Sagar Jagtap
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to pass ResultSet object from servlet to JSP.
Is it possible,if yes how?
Plz suggest me possible solns. ASAP.
sagar
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are forwarding to a JSP, any object you want can be attached to the request with setAttribute. However, you better be very sure that the ResultSet gets closed properly, no matter what happens.
Bill
 
Ashutosh Uprety
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can do that using setAttribute() method which will put values in the session.
But as a practice it is advisable not to do that. You can always get other ways to achieve the functionality u want.
 
Jayson Falkner
Author
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of setting objects in the session scope, use request scope. Placing objects in session scope is mainly unfavored because the object will stick around until the session times out. With request scope this is not the case.
Here is a FAQ that covers this question and provides a code example.
http://www.jspinsider.com/faq/12.view
Jayson Falkner
jayson@jspinsider.com
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic