Question

I have a requirement to set the session expiry of my j2ee application as 4 Minute 30 Seconds.

As far as I know, session config section allows only minutes .

<session-config>
    <session-timeout>
        [Minute]
    </session-timeout>
</session-config>

My question is, is it possible to enter decimal values like 4.5 (Equivalent to 4 Miute 30 Seconds)?

  <session-config>
        <session-timeout>
            4.5
        </session-timeout>
    </session-config>
Was it helpful?

Solution 2

After lots of research, I had to accept the fact that only integers are allowed under session-timeout tag . If at all if session expiry to be set in seconds, then only way left is to control it through Java.

To Answer my question, it is NOT possible to set session-expiry by seconds through web.xml

OTHER TIPS

Servlet Specification states the below

The default time out period for sessions is defined by the servlet container and can be obtained via the getMaxInactiveInterval method of the HttpSession interface. This time out can be changed by the Developer using the setMaxInactiveInterval method of the HttpSession interface. The time out periods used by these methods are defined in seconds

And so you should be able to specify the session-timout using setMaxInactiveInterval method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top