You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by James Cooley <jc...@salmonweir.net> on 2002/07/31 18:00:08 UTC

web-app_2_3.dtd and servlet spec and tomcat session-timeout expire at 0 problem.

Hi,

This came up on the xdoclet-devel mailing list. The xdoclet 
implementation takes follows the dtd saying that a session expires if 
the session-timeout is =< 0, while the spec says it will never expire if 
session-timeout is -1, Tomcat says it will not expire if session-timeout 
is < 0. Now xdoclet sets it to 0 by default while Tomcat defaults it to 
-1 meaning that Tomcat  session expire in under 30 seconds if the 
web.xml is created with xdoclet (or is manually set to 0).

http://cvs.apache.org/viewcvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/PersistentManagerBase.java?rev=1.8&content-type=text/vnd.viewcvs-markup

>   /**
>     * Indicate whether the session has been idle for longer
>     * than its expiration date as of the supplied time.
>     *
>     * FIXME: Probably belongs in the Session class.
>     */
>    protected boolean isSessionStale(Session session, long timeNow) {
>
>        int maxInactiveInterval = session.getMaxInactiveInterval();
>        if (maxInactiveInterval >= 0) {
>            int timeIdle = // Truncate, do not round up
>                (int) ((timeNow - session.getLastAccessedTime()) / 1000L);
>            if (timeIdle >= maxInactiveInterval)
>                return true;
>        }
>
>        return false;
>
>    }
>
It this a bug in the dtd comment (see below)?

James


path0s@pandora.be wrote:

>No. Check the DTD (http://java.sun.com/dtd/web-app_2_3.dtd). It clearly states this:
>
>The session-timeout element defines the default session timeout
>interval for all sessions created in this web application. The
>specified timeout must be expressed in a whole number of minutes.
>If the timeout is 0 or less, the container ensures the default
>behaviour of sessions is never to time out.
>
>Mathias 
>
>------------------------
> James Cooley <jc...@salmonweir.net> wrote:
>------------------------
>Hi,
>  
>
>>I noticed Tomcat 4.0.4 was timing out after about 30 seconds and on 
>>looking at the servlet (2.3) spec it says that if the session timeout is 
>>-1 then the session will not expire which seems at odds with the xdoclet 
>>statement that:
>>
>>    
>>
>>>If the timeout is 0 or less, the container ensures the default 
>>>      
>>>
>>behavior of sessions is never to time out.
>>
>>So I guess the default should be -1 instead of 0.
>>
>>James
>>
>>
>>
>>-------------------------------------------------------
>>This sf.net email is sponsored by: Dice - The leading online job board
>>for high-tech professionals. Search and apply for tech jobs today!
>>http://seeker.dice.com/seeker.epl?rel_code=31
>>_______________________________________________
>>Xdoclet-devel mailing list
>>Xdoclet-devel@lists.sourceforge.net
>>https://lists.sourceforge.net/lists/listinfo/xdoclet-devel
>>    
>>
>
>
>
>
>  
>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>