• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Bean and JSP

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
The only cure for that is hours of television radiation. And this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic