Tuesday, October 8, 2013

Session TimeOut

First of all, I would like to point out that this article has more to do with J2EE than ADF.

In some projects you may face a requirement that the application should have a session timeout set to a certain value that is persisted somewhere and a user of the system with admin privileges should be able to set this value through one of the screens.

Of course, you can simply set the session timeout in the web.xml of the application. but this method will be static and if you want to modify the session timeout you will have to modify the web.xml then restart the application.

If you want the session timeout to be set dynamically then you can use the following code:
    int timeInSeconds=2;//add your custom logic here to retrieve the timeout value
    ((HttpSession)FacesContext.getCurrentInstance().getExternalContext().
     getSession(false)).setMaxInactiveInterval(timeInSeconds);

add the above code, so that it will always be called for all the users after the login. either use Phase listener or sessionListener.

No comments:

Post a Comment