0

I have a JSF page where a popup would appear if he is idle for some period of time. 3 min 10 min etc If he is idle for some period of time a confirmDialog box would comeup with a message - "Your session has expired." and a command button id="quitConfirm" OK

Upon clicking the button ID it redirects to the home page or what ever path that you mentioned

To test this I deployed this in my local weblogic server and after a wait time of 4 min or so clicked on the commandButton OK it redirected as expected.

Issue -

after a wait time of 1 hour or so clicked on the commandButton, It did nothing
It doesnot redirect/ does nothing.

Did not change anything in the code, Just had to wait for a period of 30 min or a hour.

Actual Function

It should redirect even after a longer period of time. I mean the pop up dialogue can appear after 3 min but if you click on it after an hour or so it should redirect.

Reproducible code -

<ui:composition  xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">

   <h:panelGrid>
          <p:column>   
              <h:outputText id="bankwithdrawid"  />
                 <h:form  prependId="false">
                        <h:commandButton value="Expired" id="submit" type="submit" title="Click here to Restart" action="#{expiredMB.logout}"/>
                        <p:idleMonitor timeout="9000">
                            <p:ajax event="idle" onstart="PF('sessionTimout').show()"  />
                        </p:idleMonitor> 
                        <p:confirmDialog showEffect="fade" hideEffect="explode"
                                message="Your session has expired."
                                header="Session Timeout " widgetVar="sessionTimout" appendTo="@(body)">
                            <p:commandButton id="quitConfirm" value="OK" action="#{expiredMB.logout}" process="@this" onclick="PF('sessionTimout').hide()" />
                        </p:confirmDialog>
                </h:form>

          </p:column>
   </h:panelGrid>

 </ui:composition>   

Java bean ExpiredMB

public class ExpiredMB {

private static final Logger logger = LoggerFactory
        .getLogger(ExpiredMB.class);

public void logout() {
    ExternalContext ectx = FacesContext.getCurrentInstance()
            .getExternalContext();
    ectx.getSessionMap().clear();
    ectx.invalidateSession();
    try {
        ectx.redirect("/security/home.do?submit=Log In");
    } catch (IOException e) {
        logger.error("Problem with login." + e.getMessage());
    }
}

}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • How long is your [session timeout](https://docs.oracle.com/middleware/11119/wls/WBAPP/sessions.htm), do you enable csrf or others filters? Debugging that situation, what error do you get? – WoAiNii Mar 23 '20 at 19:42
  • This is my 30 in my xml file – suryanandan Mar 27 '20 at 15:13
  • So if you increase your idleMonitor after 30', the session is invalided and you can't call your backend class; I've never used weblogic server, so I can't specify how to manage your case, but if you try, reducing both timeout, you could see the error in your browser console and find a way to redirect even in that case or post here the error you're getting to get more specific help (try to look at [this](https://stackoverflow.com/questions/18109300/redirect-to-error-page-on-session-timeout) since it seems like your case) – WoAiNii Mar 27 '20 at 15:23
  • There is one other application in Prod with the likes of same code, and it runs fine ie even after a peroid of a 24 hours and you click on the popup dialogue, it would redirect to the login page – suryanandan Mar 27 '20 at 15:51
  • Sorry I use some wrong words, but I miss some elements, after session timeout what's the response, from logout method? Did it gets called or not? Did it raise some exceptions? Try also to take a look at [this](https://rmannibucau.wordpress.com/2016/02/18/mojarra-primefaces-and-session-timeout-login-redirection/) – WoAiNii Mar 27 '20 at 16:57
  • @MatteoZanini I changed the STATE saving method from server to client in my web xml file now it works even if I leave the popup overnight, but now I'm afraid it might impact other functionalities in the application javax.faces.STATE_SAVING_METHOD server javax.faces.STATE_SAVING_METHOD client – suryanandan Mar 29 '20 at 07:06
  • and there wew no 'errors' anywhere? No view-expired exceptions? Check and handle those. Lots of info on SO on this exception – Kukeltje Apr 01 '20 at 06:41

0 Answers0