tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session StandardSession.java
Date Tue, 30 May 2000 21:29:49 GMT
craigmcc    00/05/30 14:29:49

  Modified:    proposals/catalina build.xml
               proposals/catalina/src/conf server.xml
               proposals/catalina/src/share/org/apache/tomcat Response.java
                        Session.java
               proposals/catalina/src/share/org/apache/tomcat/connector
                        HttpRequestBase.java HttpResponseBase.java
                        RequestBase.java ResponseBase.java
                        ResponseStream.java
               proposals/catalina/src/share/org/apache/tomcat/connector/test
                        HttpProcessor.java
               proposals/catalina/src/share/org/apache/tomcat/core
                        StandardWrapperValve.java
               proposals/catalina/src/share/org/apache/tomcat/session
                        StandardSession.java
  Log:
  Miscellaneous tweaks and bugfixes:
  
  Session/StandardSession:  Implement isValid() method to avoid having
  to access a property (trying to force an IllegalStateException) to test
  session validity.
  
  Response/ResponseBase:  Add finishResponse() method so containers do not
  have to know whether the output stream or writer was used.
  
  ResponseStream:  Add closed() method for detection.
  
  HttpResponseBase:  Clean up acquiring the current session (if any) to see
  if we need to encode URLs or return session cookies.
  
  RequestBase:  Clean up bug returning a non-string request attribute.
  
  HttpRequestBase:  Use the new session validity test.
  
  HttpProcessor:  Report exceptions when closing the socket (will probably
  need to be removed again, but useful in debugging).
  
  StandardWrapperValve:  Use the new finishResponse() method.
  
  Revision  Changes    Path
  1.15      +1 -1      jakarta-tomcat/proposals/catalina/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/build.xml,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- build.xml	2000/05/16 20:25:39	1.14
  +++ build.xml	2000/05/30 21:29:41	1.15
  @@ -80,6 +80,6 @@
     </target>
   
     <!-- Clean up and compile everything -->
  -  <target name="all" depends="clean,dist.clean,main,tomcat,watchdog,dist"/>
  +  <target name="all" depends="clean,dist.clean,main,tomcat,dist"/>
   
   </project>
  
  
  
  1.29      +8 -0      jakarta-tomcat/proposals/catalina/src/conf/server.xml
  
  Index: server.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/conf/server.xml,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- server.xml	2000/05/22 20:10:54	1.28
  +++ server.xml	2000/05/30 21:29:41	1.29
  @@ -67,6 +67,14 @@
   		timestamp="true"/>
         </Context>
   
  +      <!-- Struts Example Context -->
  +      <Context path="/struts" docBase="c:\Jakarta\build\struts\example"
  +              debug="0">
  +        <Logger className="org.apache.tomcat.logger.FileLogger"
  +                prefix="struts_log." suffix=".txt"
  +                timestamp="true"/>
  +      </Context>
  +
       </Host>
   
     </Engine>
  
  
  
  1.8       +19 -10    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Response.java
  
  Index: Response.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Response.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Response.java	2000/05/16 20:25:44	1.7
  +++ Response.java	2000/05/30 21:29:42	1.8
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Response.java,v
1.7 2000/05/16 20:25:44 craigmcc Exp $
  - * $Revision: 1.7 $
  - * $Date: 2000/05/16 20:25:44 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Response.java,v
1.8 2000/05/30 21:29:42 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2000/05/30 21:29:42 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -15,7 +15,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    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
  @@ -23,15 +23,15 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:  
  - *       "This product includes software developed by the 
  + *    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 
  + *    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"
  @@ -59,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   
   package org.apache.tomcat;
  @@ -80,7 +80,7 @@
    * based on the processing of a corresponding <code>Request</code>.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2000/05/16 20:25:44 $
  + * @version $Revision: 1.8 $ $Date: 2000/05/30 21:29:42 $
    */
   
   public interface Response {
  @@ -177,6 +177,15 @@
        * @exception IOException if an input/output error occurs
        */
       public ServletOutputStream createOutputStream() throws IOException;
  +
  +
  +    /**
  +     * Perform whatever actions are required to flush and close the output
  +     * stream or writer, in a single operation.
  +     *
  +     * @exception IOException if an input/output error occurs
  +     */
  +    public void finishResponse() throws IOException;
   
   
       /**
  
  
  
  1.2       +15 -9     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Session.java
  
  Index: Session.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Session.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Session.java	2000/01/20 06:33:38	1.1
  +++ Session.java	2000/05/30 21:29:42	1.2
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Session.java,v
1.1 2000/01/20 06:33:38 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/01/20 06:33:38 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Session.java,v
1.2 2000/05/30 21:29:42 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/05/30 21:29:42 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -15,7 +15,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    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
  @@ -23,15 +23,15 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:  
  - *       "This product includes software developed by the 
  + *    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 
  + *    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"
  @@ -59,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   
   package org.apache.tomcat;
  @@ -76,7 +76,7 @@
    * between requests for a particular user of a web application.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/01/20 06:33:38 $
  + * @version $Revision: 1.2 $ $Date: 2000/05/30 21:29:42 $
    */
   
   public interface Session {
  @@ -186,6 +186,12 @@
        * without triggering an exception if the session has already expired.
        */
       public void expire();
  +
  +
  +    /**
  +     * Return the <code>isValid</code> flag for this session.
  +     */
  +    public boolean isValid();
   
   
       /**
  
  
  
  1.10      +22 -37    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/HttpRequestBase.java
  
  Index: HttpRequestBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/HttpRequestBase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- HttpRequestBase.java	2000/05/13 01:12:20	1.9
  +++ HttpRequestBase.java	2000/05/30 21:29:43	1.10
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/HttpRequestBase.java,v
1.9 2000/05/13 01:12:20 craigmcc Exp $
  - * $Revision: 1.9 $
  - * $Date: 2000/05/13 01:12:20 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/HttpRequestBase.java,v
1.10 2000/05/30 21:29:43 craigmcc Exp $
  + * $Revision: 1.10 $
  + * $Date: 2000/05/30 21:29:43 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -15,7 +15,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    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
  @@ -23,15 +23,15 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:  
  - *       "This product includes software developed by the 
  + *    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 
  + *    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"
  @@ -59,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   
   package org.apache.tomcat.connector;
  @@ -93,7 +93,7 @@
    * be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.9 $ $Date: 2000/05/13 01:12:20 $
  + * @version $Revision: 1.10 $ $Date: 2000/05/30 21:29:43 $
    */
   
   public class HttpRequestBase
  @@ -133,9 +133,9 @@
        * The set of SimpleDateFormat formats to use in getDateHeader().
        */
       protected static SimpleDateFormat formats[] = {
  -	new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz",Locale.US),
  -	new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz",Locale.US),
  -	new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy",Locale.US)
  +	new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
  +	new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
  +	new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US)
       };
   
   
  @@ -223,7 +223,7 @@
       /**
        * The Principal who has been authenticated for this Request.
        */
  -    protected Principal userPrincipal;
  +    protected Principal userPrincipal = null;
   
   
       // ------------------------------------------------------------- Properties
  @@ -887,13 +887,8 @@
       public HttpSession getSession(boolean create) {
   
   	// Return the current session if it exists and is valid
  -	if (session != null) {
  -	    try {
  -		session.getSession().getCreationTime();
  -	    } catch (IllegalStateException e) {
  -		session = null;
  -	    }
  -	}
  +	if ((session != null) && !session.isValid())
  +	    session = null;
   	if (session != null)
   	    return (session.getSession());
   
  @@ -904,14 +899,9 @@
   		session = manager.findSession(requestedSessionId);
   	    } catch (IOException e) {
   		session = null;
  -	    }
  -	    if (session != null) {
  -		try {
  -		    session.getSession().getCreationTime();
  -		} catch (IllegalStateException e) {
  -		    session = null;
  -		}
   	    }
  +	    if ((session != null) && !session.isValid())
  +	        session = null;
   	    if (session != null)
   		return (session.getSession());
   	}
  @@ -987,15 +977,10 @@
   	} catch (IOException e) {
   	    session = null;
   	}
  -	if (session != null) {
  -	    try {
  -		session.getSession().getCreationTime();
  -		return (true);
  -	    } catch (IllegalStateException e) {
  -		;
  -	    }
  -	}
  -	return (false);
  +	if ((session != null) && session.isValid())
  +	    return (true);
  +	else
  +	    return (false);
   
       }
   
  
  
  
  1.9       +40 -35    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/HttpResponseBase.java
  
  Index: HttpResponseBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/HttpResponseBase.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- HttpResponseBase.java	2000/05/16 20:25:46	1.8
  +++ HttpResponseBase.java	2000/05/30 21:29:43	1.9
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/HttpResponseBase.java,v
1.8 2000/05/16 20:25:46 craigmcc Exp $
  - * $Revision: 1.8 $
  - * $Date: 2000/05/16 20:25:46 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/HttpResponseBase.java,v
1.9 2000/05/30 21:29:43 craigmcc Exp $
  + * $Revision: 1.9 $
  + * $Date: 2000/05/30 21:29:43 $
    *
    * ====================================================================
    *
  @@ -93,7 +93,7 @@
    * methods need to be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.8 $ $Date: 2000/05/16 20:25:46 $
  + * @version $Revision: 1.9 $ $Date: 2000/05/30 21:29:43 $
    */
   
   public class HttpResponseBase
  @@ -245,26 +245,6 @@
   
   
       /**
  -     * Return the valid session with which our current request is associated,
  -     * if there is one; otherwise, return <code>null</code.
  -     */
  -    protected HttpSession getSession() {
  -
  -	HttpSession session =
  -	    ((HttpServletRequest) request.getRequest()).getSession(false);
  -	if (session == null)
  -	    return (null);
  -	try {
  -	    session.getCreationTime();	// Validity test
  -	} catch (IllegalStateException e) {
  -	    session = null;
  -	}
  -	return (session);
  -
  -    }
  -
  -
  -    /**
        * Returns a default status message for the specified HTTP status code.
        *
        * @param status The status code for which a message is desired
  @@ -373,10 +353,10 @@
       private boolean isEncodeable(String location) {
   
   	// Are we in a valid session that is not using cookies?
  -	HttpSession session = getSession();
  +	HttpServletRequest hreq = (HttpServletRequest) request.getRequest();
  +	HttpSession session = hreq.getSession(false);
   	if (session == null)
   	    return (false);
  -	HttpServletRequest hreq = (HttpServletRequest) request.getRequest();
   	if (hreq.isRequestedSessionIdFromCookie())
   	    return (false);
   
  @@ -409,6 +389,20 @@
       }
   
   
  +    private void log(String message) {
  +	org.apache.tomcat.Logger logger =
  +	  context.getParent().getParent().getLogger();
  +	logger.log(message);
  +    }
  +
  +
  +    private void log(String message, Throwable throwable) {
  +	org.apache.tomcat.Logger logger =
  +	  context.getParent().getParent().getLogger();
  +	logger.log(message, throwable);
  +    }
  +
  +
       /**
        * Send the HTTP response headers, if this has not already occurred.
        */
  @@ -431,13 +425,18 @@
   	    outputWriter.print(message);
   	}
   	outputWriter.print("\r\n");
  +//	log(request.getRequest().getProtocol() + " " + status + " " + message);
   
   	// Send the content-length and content-type headers (if any)
  -	if (getContentType() != null)
  +	if (getContentType() != null) {
   	    outputWriter.print("Content-Type: " + getContentType() + "\r\n");
  -	if (getContentLength() >= 0)
  +//	    log(" Content-Type: " + getContentType());
  +	}
  +	if (getContentLength() >= 0) {
   	    outputWriter.print("Content-Length: " + getContentLength() +
   			       "\r\n");
  +//	    log("  Content-Length: " + getContentLength());
  +	}
   
   	// Send all specified headers (if any)
   	Enumeration names = headers.keys();
  @@ -451,13 +450,14 @@
   		outputWriter.print(": ");
   		outputWriter.print(value);
   		outputWriter.print("\r\n");
  +//		log(" " + name + ": " + value);
   	    }
   	}
   
   	// Add the session ID cookie if necessary
   	// FIXME - if we used to have a session, expire the old cookie?
   	HttpServletRequest hreq = (HttpServletRequest) request.getRequest();
  -	HttpSession session = getSession();
  +	HttpSession session = hreq.getSession(false);
   	if ((session != null) && session.isNew() &&
   	    !hreq.isRequestedSessionIdFromURL()) {
   	    Cookie cookie = new Cookie(Constants.SessionCookie,
  @@ -479,6 +479,7 @@
   	    outputWriter.print("Set-Cookie: ");
   	    outputWriter.print(RequestUtil.encodeCookie(cookie));
   	    outputWriter.print("\r\n");
  +//	    log(" Set-Cookie: " + RequestUtil.encodeCookie(cookie));
   	}
   
   	// Send a terminating blank line to mark the end of the headers
  @@ -722,9 +723,11 @@
        */
       public String encodeRedirectURL(String url) {
   
  -	if (isEncodeable(toAbsolute(url)))
  -	    return (toEncoded(url, getSession().getId()));
  -	else
  +	if (isEncodeable(toAbsolute(url))) {
  +	    HttpServletRequest hreq =
  +	      (HttpServletRequest) request.getRequest();
  +	    return (toEncoded(url, hreq.getSession().getId()));
  +	} else
   	    return (url);
   
       }
  @@ -754,9 +757,11 @@
        */
       public String encodeURL(String url) {
   
  -	if (isEncodeable(toAbsolute(url)))
  -	    return (toEncoded(url, getSession().getId()));
  -	else
  +	if (isEncodeable(toAbsolute(url))) {
  +	    HttpServletRequest hreq =
  +	      (HttpServletRequest) request.getRequest();
  +	    return (toEncoded(url, hreq.getSession().getId()));
  +	} else
   	    return (url);
   
       }
  
  
  
  1.10      +11 -11    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java
  
  Index: RequestBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- RequestBase.java	2000/05/05 22:45:35	1.9
  +++ RequestBase.java	2000/05/30 21:29:43	1.10
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java,v
1.9 2000/05/05 22:45:35 craigmcc Exp $
  - * $Revision: 1.9 $
  - * $Date: 2000/05/05 22:45:35 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java,v
1.10 2000/05/30 21:29:43 craigmcc Exp $
  + * $Revision: 1.10 $
  + * $Date: 2000/05/30 21:29:43 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -15,7 +15,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    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
  @@ -23,15 +23,15 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:  
  - *       "This product includes software developed by the 
  + *    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 
  + *    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"
  @@ -59,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   
   package org.apache.tomcat.connector;
  @@ -94,7 +94,7 @@
    * the connector-specific methods need to be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.9 $ $Date: 2000/05/05 22:45:35 $
  + * @version $Revision: 1.10 $ $Date: 2000/05/30 21:29:43 $
    */
   
   public abstract class RequestBase
  @@ -580,7 +580,7 @@
        */
       public Object getAttribute(String name) {
   
  -	return ((String) attributes.get(name));
  +	return (attributes.get(name));
   
       }
   
  
  
  
  1.11      +43 -10    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java
  
  Index: ResponseBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ResponseBase.java	2000/05/16 20:25:46	1.10
  +++ ResponseBase.java	2000/05/30 21:29:43	1.11
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java,v
1.10 2000/05/16 20:25:46 craigmcc Exp $
  - * $Revision: 1.10 $
  - * $Date: 2000/05/16 20:25:46 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java,v
1.11 2000/05/30 21:29:43 craigmcc Exp $
  + * $Revision: 1.11 $
  + * $Date: 2000/05/30 21:29:43 $
    *
    * ====================================================================
    *
  @@ -87,7 +87,7 @@
    * the connector-specific methods need to be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.10 $ $Date: 2000/05/16 20:25:46 $
  + * @version $Revision: 1.11 $ $Date: 2000/05/30 21:29:43 $
    */
   
   public abstract class ResponseBase
  @@ -339,6 +339,38 @@
   
   
       /**
  +     * Perform whatever actions are required to flush and close the output
  +     * stream or writer, in a single operation.
  +     *
  +     * @exception IOException if an input/output error occurs
  +     */
  +    public void finishResponse() throws IOException {
  +
  +	// If no stream has been requested yet, get one so we can
  +	// flush the necessary headers
  +	if (this.stream == null) {
  +	    ServletOutputStream sos = getOutputStream();
  +	    sos.close();
  +	    return;
  +	}
  +
  +	// If our stream is closed, no action is necessary
  +	if ( ((ResponseStream) stream).closed() )
  +	    return;
  +
  +	// Flush and close the appropriate output mechanism
  +	if (writer != null) {
  +	    writer.flush();
  +	    writer.close();
  +	} else {
  +	    stream.flush();
  +	    stream.close();
  +	}
  +
  +    }
  +
  +
  +    /**
        * Return the content length that was set or calculated for this Response.
        */
       public int getContentLength() {
  @@ -505,16 +537,17 @@
        */
       public PrintWriter getWriter() throws IOException {
   
  +	if (writer != null)
  +	    return (writer);
  +
   	if (stream != null)
   	    throw new IllegalStateException
   		(sm.getString("responseBase.getWriter.ise"));
   
  -	if (writer == null) {
  -	    OutputStreamWriter osr =
  -		new OutputStreamWriter(createOutputStream(),
  -				       getCharacterEncoding());
  -	    writer = new PrintWriter(osr);
  -	}
  +	stream = createOutputStream();
  +	OutputStreamWriter osr =
  +	  new OutputStreamWriter(stream, getCharacterEncoding());
  +	writer = new PrintWriter(osr);
   	return (writer);
   
       }
  
  
  
  1.6       +14 -4     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseStream.java
  
  Index: ResponseStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseStream.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ResponseStream.java	2000/05/22 04:57:22	1.5
  +++ ResponseStream.java	2000/05/30 21:29:43	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseStream.java,v
1.5 2000/05/22 04:57:22 remm Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/05/22 04:57:22 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseStream.java,v
1.6 2000/05/30 21:29:43 craigmcc Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/05/30 21:29:43 $
    *
    * ====================================================================
    *
  @@ -79,7 +79,7 @@
    * enforce not writing more than that many bytes on the underlying stream.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.5 $ $Date: 2000/05/22 04:57:22 $
  + * @version $Revision: 1.6 $ $Date: 2000/05/30 21:29:43 $
    */
   
   public class ResponseStream
  @@ -203,6 +203,16 @@
   
   
       // -------------------------------------------------------- Package Methods
  +
  +
  +    /**
  +     * Has this response stream been closed?
  +     */
  +    boolean closed() {
  +
  +	return (this.closed);
  +
  +    }
   
   
       /**
  
  
  
  1.12      +18 -6     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/test/HttpProcessor.java
  
  Index: HttpProcessor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/test/HttpProcessor.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- HttpProcessor.java	2000/05/07 20:24:07	1.11
  +++ HttpProcessor.java	2000/05/30 21:29:47	1.12
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/test/HttpProcessor.java,v
1.11 2000/05/07 20:24:07 nacho Exp $
  - * $Revision: 1.11 $
  - * $Date: 2000/05/07 20:24:07 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/test/HttpProcessor.java,v
1.12 2000/05/30 21:29:47 craigmcc Exp $
  + * $Revision: 1.12 $
  + * $Date: 2000/05/30 21:29:47 $
    *
    * ====================================================================
    *
  @@ -103,7 +103,7 @@
    * the request.  When the processor is completed, it will recycle itself.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.11 $ $Date: 2000/05/07 20:24:07 $
  + * @version $Revision: 1.12 $ $Date: 2000/05/30 21:29:47 $
    */
   
   final class HttpProcessor
  @@ -654,15 +654,27 @@
   
   	// Finish up the handling of the request
   	try {
  +	    if (input != null)
  +	        input.close();
  +	} catch (IOException e) {
  +	    log("FIXME-Exception closing input", e);
  +	}
  +	try {
   	    if (output != null)
   		output.flush();
  +	} catch (IOException e) {
  +	    log("FIXME-Exception flushing output", e);
  +	}
  +	try {
  +	    if (output != null)
  +		output.close();
   	} catch (IOException e) {
  -	    ;
  +	    log("FIXME-Exception closing output", e);
   	}
   	try {
   	    socket.close();
   	} catch (IOException e) {
  -	    ;
  +	    log("FIXME-Exception closing socket", e);
   	}
   	socket = null;
   
  
  
  
  1.10      +5 -22     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java
  
  Index: StandardWrapperValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- StandardWrapperValve.java	2000/05/16 20:25:51	1.9
  +++ StandardWrapperValve.java	2000/05/30 21:29:48	1.10
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java,v
1.9 2000/05/16 20:25:51 craigmcc Exp $
  - * $Revision: 1.9 $
  - * $Date: 2000/05/16 20:25:51 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java,v
1.10 2000/05/30 21:29:48 craigmcc Exp $
  + * $Revision: 1.10 $
  + * $Date: 2000/05/30 21:29:48 $
    *
    * ====================================================================
    *
  @@ -91,7 +91,7 @@
    * <code>StandardWrapper</code> container implementation.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.9 $ $Date: 2000/05/16 20:25:51 $
  + * @version $Revision: 1.10 $ $Date: 2000/05/30 21:29:48 $
    */
   
   final class StandardWrapperValve
  @@ -235,24 +235,7 @@
   	}
   
   	// Finish flushing the output buffer as necessary
  -	PrintWriter writer = null;
  -	try {
  -	    writer = sres.getWriter();
  -	    try {
  -		writer.flush();
  -		writer.close();
  -	    } catch (Throwable t) {
  -		;
  -	    }
  -	} catch (IllegalStateException e) {
  -	    try {
  -		ServletOutputStream stream = sres.getOutputStream();
  -		stream.flush();
  -		stream.close();
  -	    } catch (Throwable t) {
  -		;
  -	    }
  -	}
  +	response.finishResponse();
   
       }
   
  
  
  
  1.4       +30 -16    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardSession.java
  
  Index: StandardSession.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardSession.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StandardSession.java	2000/05/16 22:50:39	1.3
  +++ StandardSession.java	2000/05/30 21:29:48	1.4
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardSession.java,v
1.3 2000/05/16 22:50:39 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/05/16 22:50:39 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardSession.java,v
1.4 2000/05/30 21:29:48 craigmcc Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/05/30 21:29:48 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -15,7 +15,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    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
  @@ -23,15 +23,15 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:  
  - *       "This product includes software developed by the 
  + *    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 
  + *    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"
  @@ -59,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   
   package org.apache.tomcat.session;
  @@ -95,7 +95,7 @@
    * HttpSession view of this instance back to a Session view.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2000/05/16 22:50:39 $
  + * @version $Revision: 1.4 $ $Date: 2000/05/30 21:29:48 $
    */
   
   final class StandardSession
  @@ -389,6 +389,16 @@
   
   
       /**
  +     * Return the <code>isValid</code> flag for this session.
  +     */
  +    public boolean isValid() {
  +
  +	return (this.isValid);
  +
  +    }
  +
  +
  +    /**
        * Release all object references, and initialize instance variables, in
        * preparation for reuse of this object.
        */
  @@ -411,17 +421,21 @@
       }
   
   
  -    // ------------------------------------------------ Session Package Methods
  -
  -
       /**
  -     * Return the <code>isValid</code> flag for this session.
  +     * Return a string representation of this object.
        */
  -    boolean isValid() {
  +    public String toString() {
   
  -	return (this.isValid);
  +	StringBuffer sb = new StringBuffer();
  +	sb.append("StandardSession[");
  +	sb.append(id);
  +	sb.append("]");
  +	return (sb.toString());
   
       }
  +
  +
  +    // ------------------------------------------------ Session Package Methods
   
   
       /**
  
  
  

Mime
View raw message