Our application requires that we serialize some of the user’s session data to the filesystem if their session expires. We would serialize it as is coming in but that would be too expensive due to the nature of our application.
If we can figure out a way to hook some sort of ‘onSessionEnd’ method we could run the cleanup code then.
You need to setup a
HttpSessionListenerfor your application.There is a method on the interface called
onSessionDestroythat shall be called when the session ends and you can perform serialization right then.To setup the listener, you add into
web.xml: