Closing a Wicket Session

I use a class for a session that extends org.apache.wicket.protocol.http.WebSession; I need a method that is called when this session expires due to a logout or timeout. but I didn’t find anything. How can i do this?

+3
source share
2 answers

You can do it at the Wicket level as follows:

redefining implementation of SessionStore - redefine 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 a drawback: when the session expires (which is created by the servlet container), this code will not be called. In other words, you can only handle an event for a session caused by the gate itself.

API HttpSessionListener - ,

HttpSesionListener#sessionDestroyed(HttpSessionEvent se)

WEB-INF/web.xml

<listener>
  <listener-class>
     your.listener.class.full.qualified.name
  </listener-class>
</listener>
+7

Session.java , , - HttpSession.

public void onInvalidate(){
}
0

Source: https://habr.com/ru/post/1713565/


All Articles