This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes HttpSession and Session Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "HttpSession and Session Bean" Watch "HttpSession and Session Bean" New topic
Author

HttpSession and Session Bean

Kalpana Balasubramanian
Greenhorn

Joined: Dec 22, 2005
Posts: 8
Can anyone please clarify me this question.
Whether the userstate maintained in HttpSession can be made avaiable in EJB Stateful/Stateless session bean?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Well, the EJB doesn't have direct access to the HttpSession but you can pass the session to the EJB as a parameter (assuming everything in it is Serializable). Not a good thing to do though, since it ties your EJB method to a web client and any cahnges your EJB method makes to the HttpSession will not be reflected in the actual HttpSession itself.
[ March 19, 2007: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

So in that case, you would have to get the stuff out of the HttpSession, put it into some other class that you create, pass that to the EJB, do stuff, and put the changes into that new class, return that, then take it out of that object, and put it into the HttpSession.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Kalpana Balasubramanian
Greenhorn

Joined: Dec 22, 2005
Posts: 8
Thanks for the help.

I did that way only, I created a User class which is passed back and forth with the updated information. It is working fine.

Thanks again!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpSession and Session Bean
 
Similar Threads
Accessing session or application attributes from within a JavaBean
Diff between HttpSession and Stateful Session bean
how to save data for an e-store
httpsession objects and stateful session beans
Passing data between JSP, Bean and Servlet session