How can I access request headers from a SessionListener?
I need to set a timeout on the current session when it is created. The timeout needs to vary based on a header in the HttpServletRequest. I already have a SessionListener (implements HttpSessionListener) that logs the creation and destruction of new sessions, and it seems to be the most logical place to set the timeout.
I’ve tried the following, but it always sets ctx to null.
FacesContext ctx = FacesContext.getCurrentInstance();
The
HttpSessionListenerdoes not have access to the request because it is invoked when no request has been made—to notify of session destruction.So, a
FilterorServletwould be better places to examine the request and specify the session timeout.