File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes servlet-jsp communication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet-jsp communication" Watch "servlet-jsp communication" New topic

servlet-jsp communication

Sagar Jagtap

Joined: Jul 09, 2001
Posts: 1
I want to pass ResultSet object from servlet to JSP.
Is it possible,if yes how?
Plz suggest me possible solns. ASAP.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
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.
Ashutosh Uprety
Ranch Hand

Joined: Nov 30, 2000
Posts: 39
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
Ranch Hand

Joined: May 07, 2001
Posts: 57
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.
Jayson Falkner

Jayson Falkner<br /><br />Author of <a href="" target="_blank" rel="nofollow">Servlets and JavaServer Pages; the J2EE Web Tier</a>
I agree. Here's the link:
subject: servlet-jsp communication
It's not a secret anymore!