This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes HttpSession in bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "HttpSession in bean" Watch "HttpSession in bean" New topic
Author

HttpSession in bean

Howard Ralston
Ranch Hand

Joined: Jun 25, 2001
Posts: 105
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!


<a href="http://www.getlocaldeals.com" target="_blank" rel="nofollow">Free local coupons</a>
Adam Kreiss
Ranch Hand

Joined: Sep 12, 2005
Posts: 35
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

Joined: Jun 25, 2001
Posts: 105
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.
 
Don't get me started about those stupid light bulbs.
 
subject: HttpSession in bean
 
Similar Threads
JSTL 1.1 - Get value from method of an Obj and set it to a variable
calling business delegate object from client
jsp:setProperty question
JSTL 1.0 - Get value of from an object when fn cannot be used
how to maintain the state of checkboxes across page