my dog learned polymorphism
The moose likes EJB and other Java EE Technologies and the fly likes How to close a session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to close a session" Watch "How to close a session" New topic

How to close a session

Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146
I have made a session using stateful session bean. Please tell me how to close the session when user logs out.
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Handle the code in ejbRemove and make sure client calls remove before logging out. However if the client session expires, or the client loses the connection with the bean before calling remove, then you are still safe, because the container will first passivate the bean and later on will remove the bean calling ejbRemove anyway. As you can see you might not care about calling remove at all, but by doing so you give the container a hint that the SFSB could be discharged at any time.

I think, therefore I exist -- Rene Descartes
I agree. Here's the link:
subject: How to close a session
It's not a secret anymore!