Search code examples
jspsessiontimeoutweb.xml

Need to access session-timeout value in JSP


I have a standard Tomcat/Spring application, with session timeout configured in web.xml :

<session-config>
<session-timeout>15</session-timeout>
</session-config>

I need to access the timeout setting in a JSP:

Properties.prototype.setProperty({ 
    'sessionTimeOut' : "<c:out value='${session.sessionTimeOutInterval}'/>",
});

Any ideas on how to do that? It is possible to add a filter that sets session timeout interval as an attribute:

session.setAttribute("sessionTimeOutInterval", session.getMaxInactiveInterval()); 

But I'd rather avoid adding a filter.

What would be a better way of making this value available in the JSP?


Solution

  • Here is one way.

    ${pageContext.session.maxInactiveInterval}