aspose file tools*
The moose likes Servlets and the fly likes How to pass a class object from servlet to jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to pass a class object from servlet to jsp page" Watch "How to pass a class object from servlet to jsp page" New topic
Author

How to pass a class object from servlet to jsp page

Vinoth Thirunavukarasu
Ranch Hand

Joined: Dec 18, 2008
Posts: 164

Hi,
Anybody tell I want to pass a class object from servlet page to a jsp page How can i do that.


Java Best Practices
Linux Best Practices
Amortization Calculator

Manuel Leiria
Ranch Hand

Joined: Jul 13, 2007
Posts: 171
Put the object in a session variable.Something like this:


Manuel Leiria<br /> <br />--------------<br />Peace cannot be kept by force; it can only be achieved by understanding. <br /> Albert Einstein
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
If you are forwarding to the JSP, attaching the reference to the request is an alternative to a session variable. See the JavaDocs for the javax.servlet.ServletRequest interface - setAttribute and getAttribute methods.

If on the other hand you are redirecting to the JSP, you can only use the session since a new request will be created.

[picky-mode] Typically you dont "pass" an object, you pass a reference to the object. Using the wrong terms leads to sloppy thinking[/picky-mode]

Bill


Java Resources at www.wbrogden.com
 
 
subject: How to pass a class object from servlet to jsp page
 
Similar Threads
interaction between class and jsp
Passing object from JSP tp Servlet
Pass HTTPSession to ASP
servlet to jsp
Session expires ,user session expires when online