Forums Register Login

Servlet Timeout in two ways

+Pie Number of slices to send: Send
Hi All,

There are two ways of setting session time-out for servlet. one is giving in web.xml and another is setting the Inactive interval by calling setMaxInactiveInterval on HttpSession.

What are the conceptual differences between these two ways?

Regards,
Anant
+Pie Number of slices to send: Send
There is no conceptual difference, as both settings affect the same parameter. The one in web.xml is used if setMaxInactiveInterval is not called.
[ March 15, 2007: Message edited by: Ulf Dittmer ]
+Pie Number of slices to send: Send
Be careful that the parameter for setMaxInactiveInterval is expressed in seconds, whereas the one in the deployment descriptor is in minutes.
+Pie Number of slices to send: Send
There is one more difference.

When we configure session timeout in web.xml, it is applicable to all the sessions created.

When we call setMaxInactiveInterval(int interval) on a session object, then the timeout is set only for that specific session object.

If you have specified a timeout value in web.xml and also calling setMaxInactiveInterval(int interval) on a session object, then for that session object, value set in setMaxInactiveInterval() will be considered for timeout.
+Pie Number of slices to send: Send
thanks all. i understood the difference..
A timing clock, fuse wire, high explosives and a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 34481 times.
Similar Threads
Setting HttpOnly and Secure attributes in Struts2
forwarding xml cotent from servlet to a jsp
Servlet Calling?
Relation between char-set and encoding
How to Get a String attribute from Request Using EL?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:45:47.