You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@locus.apache.org on 2000/05/12 04:32:03 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util Reaper.java SessionUtil.java

costin      00/05/11 19:32:03

  Modified:    src/share/org/apache/tomcat/session StandardManager.java
                        StandardSession.java StandardSessionManager.java
               src/share/org/apache/tomcat/util SessionUtil.java
  Added:       src/share/org/apache/tomcat/util Reaper.java
  Removed:     src/share/org/apache/tomcat/catalina Adapter.java
                        Container.java Context.java ContextConfig.java
                        Engine.java Host.java Interceptor.java
                        Lifecycle.java LifecycleException.java Loader.java
                        Logger.java Manager.java Realm.java Request.java
                        Resources.java Response.java Session.java
                        Store.java Wrapper.java WrapperConfig.java
                        WrapperParam.java WrapperRole.java
               src/share/org/apache/tomcat/session ApplicationSession.java
                        ManagerBase.java Reaper.java ServerSession.java
                        ServerSessionManager.java
  Log:
  - Removed ServerSession - it wasn't used in a while, StandardSession has more functionality.
  
  - Removed dependencies on tomcat/catalina, removed tomcat/catalina. The package was an
  early attempt to keep the 2 projects in sync - now it's outdated and too confusing.
  
  Right now the session management in tomcat is implemented in StandardSession and
  StandardManager. The link between tomcat and those 2 objects is SessionManager.
  
  SessionManager will become a per/Context object ( as requested and agreed few months
  ago ).
  
  - Reaper still exist in util - it's usefull in itself, will me made a general util.
  
  Revision  Changes    Path
  1.4       +255 -39   jakarta-tomcat/src/share/org/apache/tomcat/session/StandardManager.java
  
  Index: StandardManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/StandardManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StandardManager.java	2000/02/14 04:59:41	1.3
  +++ StandardManager.java	2000/05/12 02:31:58	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/StandardManager.java,v 1.3 2000/02/14 04:59:41 costin Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/02/14 04:59:41 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/StandardManager.java,v 1.4 2000/05/12 02:31:58 costin Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/05/12 02:31:58 $
    *
    * ====================================================================
    *
  @@ -68,12 +68,12 @@
   import java.util.Enumeration;
   import java.util.Hashtable;
   import java.util.Vector;
  -import org.apache.tomcat.catalina.*;
   import javax.servlet.http.Cookie;
   import javax.servlet.http.HttpSession;
  -import org.apache.tomcat.util.StringManager;
  +import org.apache.tomcat.util.*;
   import org.w3c.dom.NamedNodeMap;
   import org.w3c.dom.Node;
  +import org.apache.tomcat.core.*;
   
   
   /**
  @@ -103,14 +103,228 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2000/02/14 04:59:41 $
  + * @version $Revision: 1.4 $ $Date: 2000/05/12 02:31:58 $
    */
   
  -public final class StandardManager
  -    extends ManagerBase
  -    implements Lifecycle, Runnable {
  +public final class StandardManager implements Runnable {
  +    // ----------------------------------------------------- Instance Variables
  +
  +
  +    /**
  +     * The Container with which this Manager is associated.
  +     */
  +    protected Container container;
  +
  +
  +    /**
  +     * The distributable flag for Sessions created by this Manager.  If this
  +     * flag is set to <code>true</code>, any user attributes added to a
  +     * session controlled by this Manager must be Serializable.
  +     */
  +    protected boolean distributable;
  +
  +
  +    /**
  +     * The descriptive information string for this implementation.
  +     */
  +    private static final String info = "ManagerBase/1.0";
  +
  +
  +    /**
  +     * The default maximum inactive interval for Sessions created by
  +     * this Manager.
  +     */
  +    protected int maxInactiveInterval = 60;
  +
  +
  +    /**
  +     * The set of previously recycled Sessions for this Manager.
  +     */
  +    protected Vector recycled = new Vector();
  +
  +
  +    /**
  +     * The set of currently active Sessions for this Manager, keyed by
  +     * session identifier.
  +     */
  +    protected Hashtable sessions = new Hashtable();
  +
  +
  +    // ------------------------------------------------------------- Properties
  +
  +
  +    /**
  +     * Return the Container with which this Manager is associated.
  +     */
  +    public Container getContainer() {
  +
  +	return (this.container);
  +
  +    }
  +
  +
  +    /**
  +     * Set the Container with which this Manager is associated.
  +     *
  +     * @param container The newly associated Container
  +     */
  +    public void setContainer(Container container) {
  +
  +	this.container = container;
  +
  +    }
  +
  +
  +    /**
  +     * Return the distributable flag for the sessions supported by
  +     * this Manager.
  +     */
  +    public boolean getDistributable() {
  +
  +	return (this.distributable);
  +
  +    }
  +
  +
  +    /**
  +     * Set the distributable flag for the sessions supported by this
  +     * Manager.  If this flag is set, all user data objects added to
  +     * sessions associated with this manager must implement Serializable.
  +     *
  +     * @param distributable The new distributable flag
  +     */
  +    public void setDistributable(boolean distributable) {
  +
  +	this.distributable = distributable;
  +
  +    }
  +
  +
  +    /**
  +     * Return descriptive information about this Manager implementation and
  +     * the corresponding version number, in the format
  +     * <code>&lt;description&gt;/&lt;version&gt;</code>.
  +     */
  +    public String getInfo() {
  +
  +	return (this.info);
  +
  +    }
  +
  +
  +    /**
  +     * Return the default maximum inactive interval (in seconds)
  +     * for Sessions created by this Manager.
  +     */
  +    public int getMaxInactiveInterval() {
  +
  +	return (this.maxInactiveInterval);
  +
  +    }
   
   
  +    /**
  +     * Set the default maximum inactive interval (in seconds)
  +     * for Sessions created by this Manager.
  +     *
  +     * @param interval The new default value
  +     */
  +    public void setMaxInactiveInterval(int interval) {
  +
  +	this.maxInactiveInterval = interval;
  +
  +    }
  +
  +
  +    // --------------------------------------------------------- Public Methods
  +
  +
  +    /**
  +     * Return the active Session, associated with this Manager, with the
  +     * specified session id (if any); otherwise return <code>null</code>.
  +     *
  +     * @param id The session id for the session to be returned
  +     *
  +     * @exception ClassNotFoundException if a deserialization error occurs
  +     *  while processing this request
  +     * @exception IllegalStateException if a new session cannot be
  +     *  instantiated for any reason
  +     * @exception IOException if an input/output error occurs while
  +     *  processing this request
  +     */
  +    public HttpSession findSession(String id) throws IOException {
  +
  +	if (id == null)
  +	    return (null);
  +	return ((HttpSession) sessions.get(id));
  +
  +    }
  +
  +
  +    /**
  +     * Return the set of active Sessions associated with this Manager.
  +     * If this Manager has no active Sessions, a zero-length array is returned.
  +     */
  +    public HttpSession[] findSessions() {
  +
  +	synchronized (sessions) {
  +	    Vector keys = new Vector();
  +	    Enumeration ids = sessions.keys();
  +	    while (ids.hasMoreElements()) {
  +		String id = (String) ids.nextElement();
  +		keys.addElement(id);
  +	    }
  +	    HttpSession results[] = new HttpSession[keys.size()];
  +	    for (int i = 0; i < results.length; i++) {
  +		String key = (String) keys.elementAt(i);
  +		results[i] = (HttpSession) sessions.get(key);
  +	    }
  +	    return (results);
  +	}
  +
  +    }
  +
  +
  +    // -------------------------------------------------------- Package Methods
  +
  +
  +    /**
  +     * Add this Session to the set of active Sessions for this Manager.
  +     *
  +     * @param session Session to be added
  +     */
  +    void add(StandardSession session) {
  +
  +	sessions.put(session.getId(), session);
  +
  +    }
  +
  +
  +    /**
  +     * Add this Session to the recycle collection for this Manager.
  +     *
  +     * @param session Session to be recycled
  +     */
  +    void recycle(StandardSession session) {
  +
  +	recycled.addElement(session);
  +
  +    }
  +
  +
  +    /**
  +     * Remove this Session from the active Sessions for this Manager.
  +     *
  +     * @param session Session to be removed
  +     */
  +    void remove(StandardSession session) {
  +
  +	sessions.remove(session.getId());
  +
  +    }
  +
  +
  +
       // ----------------------------------------------------- Instance Variables
   
   
  @@ -126,11 +340,6 @@
       private boolean configured = false;
   
   
  -    /**
  -     * The descriptive information about this implementation.
  -     */
  -    private static final String info = "StandardManager/1.0";
  -
   
       /**
        * The maximum number of active Sessions allowed, or -1 for no limit.
  @@ -194,18 +403,7 @@
       }
   
   
  -    /**
  -     * Return descriptive information about this Manager implementation and
  -     * the corresponding version number, in the format
  -     * <code>&lt;description&gt;/&lt;version&gt;</code>.
  -     */
  -    public String getInfo() {
  -
  -	return (this.info);
  -
  -    }
   
  -
       /**
        * Return the maximum number of active Sessions allowed, or -1 for
        * no limit.
  @@ -243,15 +441,33 @@
        * @exception IllegalStateException if a new session cannot be
        *  instantiated for any reason
        */
  -    public Session createSession() {
  +    public HttpSession createSession() {
   
   	if ((maxActiveSessions >= 0) &&
   	  (sessions.size() >= maxActiveSessions))
   	    throw new IllegalStateException
   		(sm.getString("standardManager.createSession.ise"));
  +
  +	// Recycle or create a Session instance
  +	StandardSession session = null;
  +	synchronized (recycled) {
  +	    int size = recycled.size();
  +	    if (size > 0) {
  +		session = (StandardSession) recycled.elementAt(size - 1);
  +		recycled.removeElementAt(size - 1);
  +	    }
  +	}
  +	if (session == null)
  +	    session = new StandardSession(this);
   
  -	return (super.createSession());
  +	// Initialize the properties of the new session and return it
  +	session.setNew(true);
  +	session.setValid(true);
  +	session.setCreationTime(System.currentTimeMillis());
  +	session.setMaxInactiveInterval(this.maxInactiveInterval);
  +	session.setId(SessionUtil.generateSessionId());
   
  +	return (session);
       }
   
   
  @@ -269,15 +485,15 @@
        *
        * @exception IllegalStateException if this component has already been
        *  configured and/or started
  -     * @exception LifecycleException if this component detects a fatal error
  +     * @exception TomcatException if this component detects a fatal error
        *  in the configuration parameters it was given
        */
       public void configure(Node parameters)
  -	throws LifecycleException {
  +	throws TomcatException {
   
   	// Validate and update our current component state
   	if (configured)
  -	    throw new LifecycleException
  +	    throw new TomcatException
   		(sm.getString("standardManager.alreadyConfigured"));
   	configured = true;
   	if (parameters == null)
  @@ -328,17 +544,17 @@
        *  configured (if required for this component)
        * @exception IllegalStateException if this component has already been
        *  started
  -     * @exception LifecycleException if this component detects a fatal error
  +     * @exception TomcatException if this component detects a fatal error
        *  that prevents this component from being used
        */
  -    public void start() throws LifecycleException {
  +    public void start() throws TomcatException {
   
   	// Validate and update our current component state
   	if (!configured)
  -	    throw new LifecycleException
  +	    throw new TomcatException
   		(sm.getString("standardManager.notConfigured"));
   	if (started)
  -	    throw new LifecycleException
  +	    throw new TomcatException
   		(sm.getString("standardManager.alreadyStarted"));
   	started = true;
   
  @@ -356,14 +572,14 @@
        * @exception IllegalStateException if this component has not been started
        * @exception IllegalStateException if this component has already
        *  been stopped
  -     * @exception LifecycleException if this component detects a fatal error
  +     * @exception TomcatException if this component detects a fatal error
        *  that needs to be reported
        */
  -    public void stop() throws LifecycleException {
  +    public void stop() throws TomcatException {
   
   	// Validate and update our current component state
   	if (!started)
  -	    throw new LifecycleException
  +	    throw new TomcatException
   		(sm.getString("standardManager.notStarted"));
   	started = false;
   
  @@ -371,7 +587,7 @@
   	threadStop();
   
   	// Expire all active sessions
  -	Session sessions[] = findSessions();
  +	HttpSession sessions[] = findSessions();
   	for (int i = 0; i < sessions.length; i++) {
   	    StandardSession session = (StandardSession) sessions[i];
   	    if (!session.isValid())
  @@ -391,7 +607,7 @@
       private void processExpires() {
   
   	long timeNow = System.currentTimeMillis();
  -	Session sessions[] = findSessions();
  +	HttpSession sessions[] = findSessions();
   
   	for (int i = 0; i < sessions.length; i++) {
   	    StandardSession session = (StandardSession) sessions[i];
  
  
  
  1.8       +30 -58    jakarta-tomcat/src/share/org/apache/tomcat/session/StandardSession.java
  
  Index: StandardSession.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/StandardSession.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- StandardSession.java	2000/05/12 01:28:15	1.7
  +++ StandardSession.java	2000/05/12 02:31:59	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/StandardSession.java,v 1.7 2000/05/12 01:28:15 jon Exp $
  - * $Revision: 1.7 $
  - * $Date: 2000/05/12 01:28:15 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/StandardSession.java,v 1.8 2000/05/12 02:31:59 costin Exp $
  + * $Revision: 1.8 $
  + * $Date: 2000/05/12 02:31:59 $
    *
    * ====================================================================
    *
  @@ -77,7 +77,6 @@
   import javax.servlet.http.HttpSessionBindingEvent;
   import javax.servlet.http.HttpSessionBindingListener;
   import javax.servlet.http.HttpSessionContext;
  -import org.apache.tomcat.catalina.*;
   import org.apache.tomcat.util.StringManager;
   
   
  @@ -93,11 +92,11 @@
    * HttpSession view of this instance back to a Session view.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2000/05/12 01:28:15 $
  + * @version $Revision: 1.8 $ $Date: 2000/05/12 02:31:59 $
    */
   
   final class StandardSession
  -    implements HttpSession, Session, Serializable {
  +    implements HttpSession, Serializable {
   
   
       // ----------------------------------------------------------- Constructors
  @@ -108,7 +107,7 @@
        *
        * @param manager The manager with which this Session is associated
        */
  -    public StandardSession(Manager manager) {
  +    public StandardSession(StandardManager manager) {
   
   	super();
   	this.manager = manager;
  @@ -153,7 +152,7 @@
       /**
        * The Manager with which this Session is associated.
        */
  -    private Manager manager = null;
  +    private StandardManager manager = null;
   
   
       /**
  @@ -230,14 +229,13 @@
        */
       public void setId(String id) {
   
  -	if ((this.id != null) && (manager != null) &&
  -	  (manager instanceof ManagerBase))
  -	    ((ManagerBase) manager).remove(this);
  +	if ((this.id != null) && (manager != null))
  +	    ((StandardManager) manager).remove(this);
   
   	this.id = id;
   
  -	if ((manager != null) && (manager instanceof ManagerBase))
  -	    ((ManagerBase) manager).add(this);
  +	if ((manager != null) )
  +	    ((StandardManager) manager).add(this);
   
       }
   
  @@ -270,7 +268,7 @@
       /**
        * Return the Manager within which this Session is valid.
        */
  -    public Manager getManager() {
  +    public StandardManager getManager() {
   
   	return (this.manager);
   
  @@ -282,7 +280,7 @@
        *
        * @param manager The new Manager
        */
  -    public void setManager(Manager manager) {
  +    public void setManager(StandardManager manager) {
   
   	this.manager = manager;
   
  @@ -356,8 +354,8 @@
       public void expire() {
   
   	// Remove this session from our manager's active sessions
  -	if ((manager != null) && (manager instanceof ManagerBase))
  -	    ((ManagerBase) manager).remove(this);
  +	if ((manager != null) && (manager instanceof StandardManager))
  +	    ((StandardManager) manager).remove(this);
   
   	// Unbind any objects associated with this session
   	Vector results = new Vector();
  @@ -395,8 +393,8 @@
   	isValid = false;
   
   	// Tell our Manager that this Session has been recycled
  -	if ((manager != null) && (manager instanceof ManagerBase))
  -	    ((ManagerBase) manager).recycle(this);
  +	if ((manager != null) && (manager instanceof StandardManager))
  +	    ((StandardManager) manager).recycle(this);
   
       }
   
  @@ -468,7 +466,7 @@
       public HttpSessionContext getSessionContext() {
   
   	if (sessionContext == null)
  -	    sessionContext = new StandardSessionContext();
  +	    sessionContext = new SessionContextImpl();
   	return (sessionContext);
   
       }
  @@ -816,57 +814,31 @@
   
   }
   
  -
  -// -------------------------------------------------------------- Private Class
  -
  -
   /**
  - * This class is a dummy implementation of the <code>HttpSessionContext</code>
  - * interface, to conform to the requirement that such an object be returned
  - * when <code>HttpSession.getSessionContext()</code> is called.
  - *
  - * @author Craig R. McClanahan
  - *
  - * @deprecated As of Java Servlet API 2.1 with no replacement.  The
  - *  interface will be removed in a future version of this API.
  + * 
  + * @author duncan@eng.sun.com
    */
  -
  -final class StandardSessionContext implements HttpSessionContext {
   
  + class SessionContextImpl implements HttpSessionContext {
   
  -    private Vector dummy = new Vector();
  -
       /**
  -     * Return the session identifiers of all sessions defined
  -     * within this context.
        *
  -     * @deprecated As of Java Servlet API 2.1 with no replacement.
  -     *  This method must return an empty <code>Enumeration</code>
  -     *  and will be removed in a future version of the API.
  +     * @deprecated
        */
  -    public Enumeration getIds() {
  -
  -	return (dummy.elements());
  -
  +    
  +    public HttpSession getSession(String sessionId) {
  +        return null;
       }
   
  -
       /**
  -     * Return the <code>HttpSession</code> associated with the
  -     * specified session identifier.
  -     *
  -     * @param id Session identifier for which to look up a session
        *
  -     * @deprecated As of Java Servlet API 2.1 with no replacement.
  -     *  This method must return null and will be removed in a
  -     *  future version of the API.
  +     * @deprecated
        */
  -    public HttpSession getSession(String id) {
   
  -	return (null);
  +    public Enumeration getIds() {
  +        // cheap hack to get an empty enum
  +        Vector v = new Vector();
   
  +        return v.elements();
       }
  -
  -
  -
   }
  
  
  
  1.6       +15 -19    jakarta-tomcat/src/share/org/apache/tomcat/session/StandardSessionManager.java
  
  Index: StandardSessionManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/StandardSessionManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StandardSessionManager.java	2000/03/01 07:51:13	1.5
  +++ StandardSessionManager.java	2000/05/12 02:32:00	1.6
  @@ -63,8 +63,8 @@
   import java.io.IOException;
   import javax.servlet.http.Cookie;
   import javax.servlet.http.HttpSession;
  -import org.apache.tomcat.catalina.*;
   import org.apache.tomcat.core.Context;
  +import org.apache.tomcat.core.TomcatException;
   import org.apache.tomcat.core.Request;
   import org.apache.tomcat.core.Response;
   import org.apache.tomcat.core.SessionManager;
  @@ -105,14 +105,12 @@
        */
       public StandardSessionManager() {
   
  -	manager = new StandardManager();
  -	if (manager instanceof Lifecycle) {
  -	    try {
  -		((Lifecycle) manager).configure(null);
  -		((Lifecycle) manager).start();
  -	    } catch (LifecycleException e) {
  +	try {
  +	    manager = new StandardManager();
  +	    manager.configure(null);
  +	    manager.start();
  +	} catch (TomcatException e) {
   		throw new IllegalStateException("" + e);
  -	    }
   	}
   
       }
  @@ -124,7 +122,7 @@
       /**
        * The Manager implementation we are actually using.
        */
  -    private Manager manager = null;
  +    private StandardManager manager = null;
   
   
       // --------------------------------------------------------- Public Methods
  @@ -139,8 +137,8 @@
       public void accessed(Context ctx, Request req, String id) {
   	HttpSession session=findSession(ctx, id);
   	if( session == null) return;
  -	if (session instanceof Session)
  -	    ((Session) session).access();
  +	if (session instanceof StandardSession)
  +	    ((StandardSession) session).access();
   
   	// cache the HttpSession - avoid another find
   	req.setSession( session );
  @@ -149,7 +147,7 @@
       // XXX should we throw exception or just return null ??
       public HttpSession findSession( Context ctx, String id ) {
   	try {
  -	    Session session = manager.findSession(id);
  +	    StandardSession session =(StandardSession)manager.findSession(id);
   	    if(session!=null)
   		return session.getSession();
   	} catch (IOException e) {
  @@ -158,7 +156,7 @@
       }
   
       public HttpSession createSession(Context ctx) {
  -	return  manager.createSession().getSession();
  +	return  ((StandardSession)manager.createSession()).getSession();
       }
   
       /**
  @@ -172,12 +170,10 @@
   	// contexts, we just want to remove the sessions of ctx!
   	// The manager will still run after that ( i.e. keep database
   	// connection open
  -	if (manager instanceof Lifecycle) {
  -	    try {
  -		((Lifecycle) manager).stop();
  -	    } catch (LifecycleException e) {
  -		throw new IllegalStateException("" + e);
  -	    }
  +	try {
  +	    manager.stop();
  +	} catch (TomcatException e) {
  +	    throw new IllegalStateException("" + e);
   	}
   
       }
  
  
  
  1.4       +8 -9      jakarta-tomcat/src/share/org/apache/tomcat/util/SessionUtil.java
  
  Index: SessionUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/SessionUtil.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SessionUtil.java	2000/02/14 04:59:43	1.3
  +++ SessionUtil.java	2000/05/12 02:32:02	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/SessionUtil.java,v 1.3 2000/02/14 04:59:43 costin Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/02/14 04:59:43 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/SessionUtil.java,v 1.4 2000/05/12 02:32:02 costin Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/05/12 02:32:02 $
    *
    * ====================================================================
    *
  @@ -66,8 +66,7 @@
   
   
   import javax.servlet.http.Cookie;
  -import org.apache.tomcat.catalina.Request;
  -import org.apache.tomcat.core.Constants;
  +import org.apache.tomcat.core.*;
   
   
   /**
  @@ -75,7 +74,7 @@
    * <code>Session</code> implementations.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2000/02/14 04:59:43 $
  + * @version $Revision: 1.4 $ $Date: 2000/05/12 02:32:02 $
    */
   
   public final class SessionUtil {
  @@ -104,10 +103,10 @@
       public static Cookie createCookie(Request req, String id) {
   
   	Cookie cookie = new Cookie(Constants.SESSION_COOKIE_NAME, id);
  -	String serverName = req.getRequest().getServerName();
  +	String serverName = req.getServerName();
   	if (serverName != null)
   	    cookie.setDomain(serverName);
  -	String contextPath = req.getRequest().getContextPath();
  +	String contextPath = req.getContext().getPath();
   	if ((contextPath != null) && (contextPath.length() > 0))
   	    cookie.setPath(contextPath);
   	else
  @@ -164,7 +163,7 @@
   	}
   
   	// Encode all absolute URLs that return to this hostname
  -	String serverName = req.getRequest().getServerName();
  +	String serverName = req.getServerName();
   	String match = "http://" + serverName;
   	if (url.startsWith("http://" + serverName))
   	    return (encode(id, url));
  
  
  
  1.1                  jakarta-tomcat/src/share/org/apache/tomcat/util/Reaper.java
  
  Index: Reaper.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  
  package org.apache.tomcat.util;
  
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.util.*;
  
  /**
   * The reaper is a background thread with which ticks every minute
   * and calls registered objects to allow reaping of old session
   * data.
   * 
   * @author James Duncan Davidson [duncan@eng.sun.com]
   */
  
  public class Reaper extends Thread {
  
      private static Reaper reaper;
      
      static {
  	reaper = new Reaper();
      }
      
      static Reaper getReaper() {
  	return reaper;
      }
  
      private int interval = 1000 * 60; //ms    
      //XXX    private ServerSessionManager serverSessionMgr;
      
      private Reaper() {
  	this.setDaemon(true);
      }
      
  //XXX     void setServerSessionManager(ServerSessionManager serverSessionMgr) {
  // 	this.serverSessionMgr = serverSessionMgr;
  //     }
      
      public void run() {
  
  	// XXX
  	// eventually, to be nice, this should know when everything
  	// goes down so that it's not continuing to tick in the background
  
  	while (true) {
  	    try {
  		this.sleep(interval);
  	    } catch (InterruptedException ie) {
  		// sometimes will happen
  	    }
  
  	    //XXX     if (serverSessionMgr != null) {
  	    // 		serverSessionMgr.reap();
  	    //     }
  	}
      }
  }