May 25 2015

Jsf session timeout

Jsf session timeout

Session timeout is a property that is assigned to the Session object. If user do not request or refresh the page with the specified time, the session will end.

Jsf session timeout can be configured in two ways

  1. Adding ‘session-timeout’ in web.xml

Configure the value for ‘session-timeout’ of ‘session-config’ element in web.xml .The value should be specified in minutes

In the below example, if user does not request or refresh for 30 minutes the container will end the session.


<web-app>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>

  1. Using setMaxInactiveInterval in code

Configure the timeout using session object’s setMaxInactiveInterval method. The values should be in seconds.

In the below example, if user does not not request or refresh for 30(30*60seconds) minutes the container will end the session.


FacesContext facesContext = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true);
session.setMaxInactiveInterval(30*60);


Copyright © 2014. All rights reserved.

Posted May 25, 2015 by answersz in category Jsf

1 thoughts on “Jsf session timeout

Leave a Comment

Your email address will not be published. Required fields are marked *

*