Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to end a session with stateful session bean?

 
Abhishek Asthana
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Anil Sadi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic