File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bean and JSP

 
Sarthishari Kumar
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am just trying to do this. Help me.
Am setting a Bean Property in a Servlet.
After that i am transferring the control to a JSP page.
i want to retrieve that property in the JSP page.
Don't want to set that Bean as a Session Object and retrieve it in the JSP page.
Can it be done??
Waiting for all ur replies
Sathish
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The most comment method of passing beans, or any other Java data, from a servlet to a JSP (assuming that you are forwarding) is to tack it onto the request via request.setAttribute().
You can then retrieve the bean in the JSP either via the request.getAttribute() method, or with the JSP useBean tag.
Your instinct to not just throw transient data onto the session is a good one. The session should be reserved for holding data that truly needs to be held for the duration of the session (login authentication is a good example).
hth,
bear
 
Sarthishari Kumar
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear
thanx for ur reply.
Can it be done in any other way??
Other than Session objects and Request Attributes can this be done??
Just curious??
Sathish
 
arul murug
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
You can store your bean in Pagecontext or some other user managed(container) object but still you need to add and pass the reference in any one of these three objects request or session or servletcontext .
Arul
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic