Issue
Is there any way for a java servlet/jsp to determine the webserver's session timeout (in seconds, minutes, etc...)? I tried looking in the HttpSession and System API, but didn't see any property for determining the webserver's session timeout. I know that this value is set in web.xml, but I am designing a java library which needs to determine this through code.
Note: I am designing for a generic webserver and cannot rely on vendor specific extensions.
Solution
HttpSession.getMaxInactiveInterval
provides this value
int getMaxInactiveInterval()
Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses. After this interval, the servlet container will invalidate the session. The maximum time interval can be set with the setMaxInactiveInterval method.
A return value of zero or less indicates that the session will never timeout.
Returns: an integer specifying the number of seconds this session remains open between client requests
Answered By - user159088