I have a question about session timeouts and JSF 2. I have my exception handler working exactly the way everyone prefers but I need to pass a value to the login page. For example, I have a typical login URL – http://www.acme.com/?companyId=company14 which in turn presents company14 with their own custom login page (using their logo). After they enter the application and do a bit of work, they read an email or 2. The session times out and a session timeout page is shown instructing the user to click Ok to proceed to the login page. How do I add ?companyId=company14 to the URL? I can hardcode it in the exception handler by using this:
requestMap.put(“companyId”, “company14”);
and then referring to it on the viewExpired.xhtml page:
<h:panelGrid id="expiredGrid" columns="1">
<f:facet name="header">
<h:outputText id="outExpireMsg" value="Your session has expired"/>
</f:facet>
<h:outputText id="outReqMessage" value="Reloading the page will require login."/>
<h:outputText value=""/>
<h:button id="okButton" type="submit" value="Ok" outcome="login?companyId=#{companyId}"/>
</h:panelGrid>
The issue is I can’t seem to save the companyId anywhere without it getting wiped out by the session timeout. I’d like to set the companyId in the exceptionhandler using this value. Any ideas?
You could set it as a cookie on login.
Then you can grab it as follows:
Note that this doesn’t expire when the server side session expires. This expires only when the browser get closed.