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.