Question

Is it possible to configure the session-timeout Programmatically in JBOSS EAP 6.1? Using @PostConstruct on session scoped beans or is there any listeners for Session creation?

Était-ce utile?

La solution

You can use HttpSession#setMaxInactiveInterval. Then you can have a class which will implement HttpSessionListener interface so whenever new session is created, you can programatically set new timeout to it.

public class MyHttpSessionListener implements HttpSessionListener {

    @Override
    public void sessionCreated(HttpSessionEvent event) {
        event.getSession().setMaxInactiveInterval(yourInterval); 
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent event){
    }
}

As far as I know, there is now way how to do this in CDI but Servlets and CDI are compliant technologies so it should work together. Note that you can inject any CDI bean to this listener.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top