You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Alex Cruikshank <al...@epitonic.com> on 2000/02/03 23:52:09 UTC

[PATCH] session timeout (was [Help please...session timeout])

The session management code has been completely replaced with new code in 
3.1M1.  It has rather sophisticated XML-Node base configuration system 
that, unfortunately, goes completely ignored by the tomcat server.  The 
relevant lines are in org.apache.tomcat.session.StandardSessionManager 
starting at line 113:
             try {
                 ((Lifecycle) manager).configure(null);   <===== null 
configuration
                 ((Lifecycle) manager).start();
             } catch (LifecycleException e) {
                 throw new IllegalStateException("" + e);
             }

Since the entire configuration system seems to be the object of some debate 
right now, I propose the following patch in the interest of keeping the 
server operable in the interim:

diff -u -r1.4 StandardSessionManager.java
--- StandardSessionManager.java 2000/01/26 17:45:10     1.4
+++ StandardSessionManager.java 2000/02/03 22:36:53
@@ -182,5 +182,17 @@

      }

+    /**
+     * Set the default session time out for the session manager.
+     *
+     * @param inSesionTimeOut time (in seconds) before an inactive session 
will expire
+     */
+    public void setSessionTimeOut( int inSessionTimeOut )
+    {
+        if ( manager != null )
+        {
+            manager.setMaxInactiveInterval( inSessionTimeOut );
+        }
+    }

  }


diff -u -r1.37 Context.java
--- Context.java        2000/02/03 07:11:51     1.37
+++ Context.java        2000/02/03 22:37:14
@@ -503,6 +503,11 @@
             //      sessionManager = 
org.apache.tomcat.session.ServerSessionManager.getManager();
             sessionManager =
                 new org.apache.tomcat.session.StandardSessionManager();
+            if ( sessionTimeOut >= 0 )
+            {
+                ((org.apache.tomcat.session.StandardSessionManager)
+                        sessionManager.setSessionTimeOut( sessionTimeOut );
+            }
         }
         return sessionManager;
      }

The effect of this change will be that the defaultSessionTimeOut set in the 
server.xml context tag will actually be the defaultSessionTimeOut.  Since 
session time out is important (and IMHO the default 60 seconds is way to 
low), I humbly beg that one of the committers make this or an equivalent 
fix soon.

Thanks,
Alex Cruikshank
Senior Software Engineer
Epitonic.com


At 09:30 AM 2/3/00 -0800, you wrote:
>Yep tried putting that in the web.xml and the same result. The timeout 
>value is
>set to 60 seconds no matter what is in the xml file(s).
>
>A quick test inserting
>session.getMaxInactiveInterval();
>into a page holding a session always returns 60 no matter what the entry
>in the XML file. As a workaround I inserted
>session.setMaxInactiveInterval(1800) in the JSP page   to keep the
>session alive for half an hour.
>
>
>Is this a known issue?
>
>Thanks,
>Interesse Michelangelo wrote:
>
> > I have similar problems using Tomcat 3.1M1 - (previous version worked fine
> > on WinNT).
> >
> > Any way did you tried to insert the following lines:
> >         <!-- session-config -->
> >             <session-config>
> >                 <session-timeout>
> >                 60      <-- in minutes, I guess !!!
> >                 </session-timeout>
> >             </session-config>
> >
> > in the web.xml file under the WEB-INF dir of your default site dir ?
> >
> > This overrides what is written in the server.xml configuration file, 
> located
> > in the Tomcat root.
> >
> > Bye,
> >
> > Michelangelo Interesse
> > ----------------------------
> >       Process Support Systems
> >                Netsiel S.p.A.
> >       * ++39-080-5092.220
> > ----------------------------
> >
> > > ----------
> > > Da:   Joseph Pearce[SMTP:jcpearce@us.oracle.com]
> > > Risposta a:   tomcat-dev@jakarta.apache.org
> > > Inviato:      giovedl 3 febbraio 2000 1.52
> > > A:    tomcat-dev@jakarta.apache.org
> > > Oggetto:      [Fwd: Help please...session timeout]
> > >
> > > <<Messaggio: RE: Help please...sess...>><<File: ATT71289.txt>>
> > > I have the same problems with my apps. Is this a known issue? Is there a
> > > workaround?
> > >
> > > Cheers,
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org