WebApplicationInitializer provides a way to programmatically represent a good portion of a standard web.xml file - the servlets, filters, listeners.
However I have
Actually WebApplicationInitializer doesn't provide it directly. But there is a way to set sessointimeout with java configuration.
You have to create a HttpSessionListner first :
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
public class SessionListener implements HttpSessionListener {
@Override
public void sessionCreated(HttpSessionEvent se) {
//here session will be invalidated by container within 30 mins
//if there isn't any activity by user
se.getSession().setMaxInactiveInterval(1800);
}
@Override
public void sessionDestroyed(HttpSessionEvent se) {
System.out.println("Session destroyed");
}
}
After this just register this listener with your servlet context which will be available in WebApplicationInitializer under method onStartup
servletContext.addListener(SessionListener.class);