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
-
How to end a session with stateful session bean? (6 messages)
- Posted by: Abhishek Asthana
- Posted on: March 28 2005 02:47 EST
Threaded Messages (6)
- How to end a session with stateful session bean? by Martin Straus on March 28 2005 10:25 EST
- How to end a session with stateful session bean? by Anil Kumar Sadineni on March 28 2005 16:41 EST
- sessionDestroyed() is not call when implicit close browser by Nam Nguyen Van on March 29 2005 02:26 EST
-
using ejbRemove() by Vikas Bodani on March 29 2005 06:58 EST
- using ejbRemove() by Anil Kumar Sadineni on March 29 2005 02:21 EST
- sessionDestroyed() is not call when implicit close browser by Anil Kumar Sadineni on March 29 2005 02:14 EST
-
using ejbRemove() by Vikas Bodani on March 29 2005 06:58 EST
- sessionDestroyed() is not call when implicit close browser by Nam Nguyen Van on March 29 2005 02:26 EST
-
How to end a session with stateful session bean?[ Go to top ]
- Posted by: Martin Straus
- Posted on: March 28 2005 10:25 EST
- in response to Abhishek Asthana
You could add a SessionEventListener (perhaps the interface's name is slightly different) to the user's session. This listener should detect the invalidation of the session and update the state of the user.
Of course, this approach is not suitable for every application. In your case, I don't see how this has anything to do with the statefull session bean... unless you're storing the user's state in it.
Cheers and happy coding,
Martin -
How to end a session with stateful session bean?[ Go to top ]
- Posted by: Anil Kumar Sadineni
- Posted on: March 28 2005 16:41 EST
- in response to Abhishek Asthana
Hi Abhishek,
You can use the HttpSessionListener to capture the session create/destroy events. If you can keep the EJBObject handle of your stateful session bean in session scope, when session time out/invalidate haoppens, the sessionDestroyed() will be called. In sessionDestroyed(), write code to get the handle from session scope and call remove() method on EJBObject.
Hope it may helps !!!
Anil Sadineni. -
sessionDestroyed() is not call when implicit close browser[ Go to top ]
- Posted by: Nam Nguyen Van
- Posted on: March 29 2005 02:26 EST
- in response to Anil Kumar Sadineni
Hi, I used to use this solution before but sessionDestroyed() only perform if we call HttpSession.invalideSession(). If user close browser without sign out, sessionDestroyed() is not call? -
using ejbRemove()[ Go to top ]
- Posted by: Vikas Bodani
- Posted on: March 29 2005 06:58 EST
- in response to Nam Nguyen Van
Well! I would like to add though i'm not sure..
the life cycle method of a stateful session bean, ejbRemove will be called when the user disconnects in someway(anyway). so how about adding the code of updating the login status in the ejbRemove method of the session bean.. i think it should work.
Regards,
Vikas -
using ejbRemove()[ Go to top ]
- Posted by: Anil Kumar Sadineni
- Posted on: March 29 2005 14:21 EST
- in response to Vikas Bodani
Well! I would like to add though i'm not sure.. the life cycle method of a stateful session bean, ejbRemove will be called when the user disconnects in someway(anyway).
Hi Vikas,
As per Sateful Session Lifecycle, the ejbRemove() will be called in two scenarios.
1. Time out
2. User calls the remove() method on EJBObject.
In sessionDestroyed(), I can call the remove() method on EJBObject to remove the stateful session bean.so how about adding the code of updating the login status in the ejbRemove method of the session bean.. i think it should work.
It will work. But, I can keep the code in another business method and call it from sessionDestroyed(). After that I call remove() on EJBObject. I think, its not good idea to keep that kind of code in ejbRemove().
Anil Sadineni -
sessionDestroyed() is not call when implicit close browser[ Go to top ]
- Posted by: Anil Kumar Sadineni
- Posted on: March 29 2005 14:14 EST
- in response to Nam Nguyen Van
Hi, I used to use this solution before but sessionDestroyed() only perform if we call HttpSession.invalideSession(). If user close browser without sign out, sessionDestroyed() is not call?
Hi Nam,
There is no way to track when the user closes the browser window. But the container will call the sessionDestroyed() after the session timed out for that perticular user session.
Anil Sadineni