Hi, I'm working on a struts based web-application that is deployed on tomcat5.0.27 under Windows OS.I have added a SessionListener class to tarck the session creation & destruction. The problem is that my SessionListener class's method public void sessionDestroyed(HttpSessionEvent se) is not being called, everytime the session times-out.
I have explicitly set session.setMaxInactiveInterval(20) at my logon page.So, If I do not do any action on a page for more than 20 seconds, the session should be expired and the method public void sessionDestroyed(HttpSessionEvent se) of SessionListener class must be called.It is not happening after I move on to certain pages, but on some other pages it is working.
Could this be Struts or tomcat5.0.27 specific issue? please help me on this.
Regards. KuldeepT. [ March 09, 2007: Message edited by: K Tewari ]
Thanks PK, I've to do some manipulation on some objects in Cache, once the logged-in user's session expires.That's why I'm interested in knowing when the session expires. But the SessionListener's sessionDestroyed() method is being called by the container only when I'm on certain pages, on others its not being called even after the timeout period elapses on that particular page. I just want to know if there is some issue with how & when this callback method is called by the container while running a struts based application.
Regards. Kuldeep. [ March 09, 2007: Message edited by: K Tewari ]
I think I know what your "random" problem is about. In some pages you may have an action with session ActionForm, and in these pages your listener is invoked if the session is expired. But in the ones with request ActionForm (or some of them) it's not done. This is due to in the pages that don't get this event thriggered you are not accessing the session object, that's it, there is no request.getSession(), so the session is not checked of its existence and validity. In the cases you have session ActionForms, this call is made by Struts in order to get the session to retrieve and store your form, but it's not the same case when the ActionForm is request scope.