File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to end a session with stateful session bean?

 
Abhishek Asthana
Ranch Hand
Posts: 146
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic