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.
The session's timeout is determined by idle time so there is no way to know when it will timeout.
However, you can calculate the next possible timeout assuming session is not being accessed,
Date expiry = new Date(session.getLastAccessedTime() + session.getMaxInactiveInterval()*1000);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With