aspose file tools*
The moose likes Servlets and the fly likes Servlet Timeout in two ways Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Timeout in two ways" Watch "Servlet Timeout in two ways" New topic
Author

Servlet Timeout in two ways

Anant Jagania
Ranch Hand

Joined: Oct 20, 2004
Posts: 49
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
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42634
    
  65
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 ]

Ping & DNS - my free Android networking tools app
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Be careful that the parameter for setMaxInactiveInterval is expressed in seconds, whereas the one in the deployment descriptor is in minutes.


[My Blog]
All roads lead to JavaRanch
Sunil Vasudevan
Ranch Hand

Joined: Mar 05, 2007
Posts: 107
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.


Sunil.V<br />SCJP2, SCWCD1.4, SCBCD1.3
Anant Jagania
Ranch Hand

Joined: Oct 20, 2004
Posts: 49
thanks all. i understood the difference..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Timeout in two ways