aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes How to end a session with stateful session bean? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to end a session with stateful session bean?" Watch "How to end a session with stateful session bean?" New topic
Author

How to end a session with stateful session bean?

Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146
Hi,
I have made shopping cart using stateful session bean. I want that when the session expires the user's loginStatus field in a database table is set to 'N'.
Can anyone please tell me how to catch this event of session getting expired. Is there any exception thrown or anything else?
Please help me.
Abhishek
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I believe that when a session bean "times out", it is removed, so you could accomplish what you want by putting this code in the bean's ejbRemove() method.


Merrill
Consultant, Sima Solutions
Anil Sadi
Greenhorn

Joined: Jan 09, 2001
Posts: 23
Hi Abhishek,

Use HttpSessionListener to capture the session create/destroy events. After you initiate the stateful session bean, keep the EJBObject handle in session scope. In sessionDestroyed() method of HttpSessionListener implementation class, keep the code to call the stateful session bean's method which can change the login status in database.

It may solve your problem!!!

Anil S.
 
Don't get me started about those stupid light bulbs.
 
subject: How to end a session with stateful session bean?