• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HttpSession in bean

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have a String object in a session that was put there earlier in an Action object, e.g. session.setAttribute("MyVariable", "MyString"), is it possible to retrieve "MyString" from the session in a non-form bean? I want to use the bean tag on a jsp but don't want to use code in the jsp to send the session to the bean, e.g. myBean.setSession(session).

Many thanks!
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you put a bean into the session (as opposed to a string), you can reference it with a <bean:whatever> tag. All you have to do is specify the name and set scope="session".

Although I'm not sure thats what you need.
 
Howard Ralston
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.
What I wanted to know is: how do I access any object in the session when I am coding a bean? If I have a Customer object stored in the session, how do I access it from a bean? I want to get values from the Customer object for comparison in the bean, then depending on the result, write a message in the jsp with the bean.
reply
    Bookmark Topic Watch Topic
  • New Topic