• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass a class object from servlet to jsp page

 
Vinoth Thirunavukarasu
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Anybody tell I want to pass a class object from servlet page to a jsp page How can i do that.
 
Manuel Leiria
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put the object in a session variable.Something like this:
 
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 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic