user2219247 user2219247 - 4 months ago 21
Java Question

Get maxInactiveInterval value in JSP page

I am trying to refresh a page when session has timedout. I am adding this into my

<head>
section of HTML:

<meta http-equiv="refresh"
content="${sessionScope['maxInactiveInterval']};url=${pageContext.servletContext.contextPath}/index.htm?reason=expired"/>


However this:
${sessionScope['maxInactiveInterval']}
or
${sessionScope.maxInactiveInterval}
prints out empty value (nothing).

I know that in JSF I can use:
#{session.maxInactiveInterval}
and it works. How to make this for in JSP page?

Answer

below line will give you maxInactiveInterval

${pageContext.session.maxInactiveInterval}

Because sessionScope maps only session-scoped variable names to their values, Where as pageContext.session gives session object for the client

You can find this in Official Documentation.