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
posted 10 years ago
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.
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.