0

I have this Spring application where I have configured the login and logout function to have an advice which logs their time of execution. But I don't know how to log the time when there is session timeout. I am using Apache Tomcat 7 web server and have configured the session timeout in the web.xml file of my web project. Thanks in advance.

suchit
  • 57
  • 9

1 Answers1

0

You can resolve this by implementing a javax.servlet.http.HttpSessionListener.

The HttpSessionListener.sessionDestroyed(HttpSessionEvent httpSessionEvent) will be invoked when the session expires.

If you annotate your implementation class with @javax.servlet.annotation.WebListener then Tomcat 7 will install and execute it for you as needed.

Steve C
  • 18,876
  • 5
  • 34
  • 37
  • Thanks @Steve, I am a newbie to Spring, kept a separate class to implement the HttpSessionListener. Still figuring it out how to weave the same into the application so the overloaded sessionDestroyed method will be called during session expiration. – suchit Jul 01 '16 at 10:25
  • Use an @WebListener as noted – Steve C Jul 01 '16 at 10:47
  • I configured it in the web.xml inside listener tag and it worked perfectly. Thanks Steve. – suchit Jul 01 '16 at 11:01