You can do it on Wicket level like this:
by overriding SessionStore implementation - override Application#newSessionStore()
@Override
protected ISessionStore newSessionStore() {
return new SecondLevelCacheSessionStore(this, new DiskPageStore()) {
@Override
protected void onUnbind(String sessionId) {
// this code is called when wicket call httpSession.invalidate()
}
};
}
but this has drawback: when session expires (which is constroled by servlet container) this code won't be called. In other words - you can handle only session destroy event which is caused by wicket itself.
On global level you can use Servlet API's HttpSessionListener - you can react on session destroy event whatever it was triggered by
HttpSesionListener#sessionDestroyed(HttpSessionEvent se)
and write this to your WEB-INF/web.xml
<listener>
<listener-class>
your.listener.class.full.qualified.name
</listener-class>
</listener>