简体   繁体   中英

How to log the time in a J2EE application from the session-timeout configuration specified in the web.xml?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM