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/src/share/org/apache/tomcat/core ResponseImpl.java
Date Sun, 05 Nov 2000 03:12:05 GMT
craigmcc    00/11/04 19:12:05

  Modified:    src/share/org/apache/tomcat/core Tag: tomcat_32
                        ResponseImpl.java
  Log:
  Although I could not reproduce a reported error ("calling a servlet with
  RequestDispatcher.include() cauases headers and cookies that were set in
  the calling servlet to disappear), I did find many cases where the
  included servlet could mess things up.  In particular, Tomcat 3.2 was not
  ignoring the following calls from an included servlet:
  - response.reset()
  - response.addCookie()
  - response.setLocale()
  - response.setContentType()
  - response.setContentLength()
  
  I also tried to get rid of the convoluted double negative logic in most
  cases, but I don't really want to mess with more of this than necessary.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.33.2.1  +20 -17    jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ResponseImpl.java
  
  Index: ResponseImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ResponseImpl.java,v
  retrieving revision 1.33
  retrieving revision 1.33.2.1
  diff -u -r1.33 -r1.33.2.1
  --- ResponseImpl.java	2000/06/30 20:21:25	1.33
  +++ ResponseImpl.java	2000/11/05 03:12:03	1.33.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ResponseImpl.java,v
1.33 2000/06/30 20:21:25 costin Exp $
  - * $Revision: 1.33 $
  - * $Date: 2000/06/30 20:21:25 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ResponseImpl.java,v
1.33.2.1 2000/11/05 03:12:03 craigmcc Exp $
  + * $Revision: 1.33.2.1 $
  + * $Date: 2000/11/05 03:12:03 $
    *
    * ====================================================================
    *
  @@ -288,13 +288,13 @@
   
   
       public void setHeader(String name, String value) {
  -	if( ! notIncluded ) return; // we are in included sub-request
  +        if( isIncluded() ) return;      // We are in an included sub-request
   	if( ! checkSpecialHeader(name, value) ) 
   	    headers.putHeader(name, value);
       }
   
       public void addHeader(String name, String value) {
  -	if( ! notIncluded ) return; // we are in included sub-request
  +        if( isIncluded() ) return;      // We are in an included sub-request
   	if( ! checkSpecialHeader(name, value) ) 
   	    headers.addHeader(name, value);
       }
  @@ -367,12 +367,14 @@
   	// Force the PrintWriter to flush its data to the output
           // stream before resetting the output stream
           //
  -	userCookies.removeAllElements();  // keep system (session) cookies
  -	contentType = Constants.DEFAULT_CONTENT_TYPE;
  -        locale = DEFAULT_LOCALE;
  -	characterEncoding = Constants.DEFAULT_CHAR_ENCODING;
  -	contentLength = -1;
  -	status = 200;
  +        if( ! isIncluded() ) {
  +            userCookies.removeAllElements();  // keep system (session) cookies
  +            contentType = Constants.DEFAULT_CONTENT_TYPE;
  +            locale = DEFAULT_LOCALE;
  +            characterEncoding = Constants.DEFAULT_CHAR_ENCODING;
  +            contentLength = -1;
  +            status = 200;
  +        }
   
   	if (usingWriter == true && writer != null)
   	    writer.flush();
  @@ -384,7 +386,7 @@
           // Clear the cookies and such
   
           // Clear the headers
  -        if( notIncluded) headers.clear();
  +        if( ! isIncluded() ) headers.clear();
       }
   
       // Reset the response buffer but not headers and cookies
  @@ -432,6 +434,7 @@
       }
   
       public void addCookie(Cookie cookie) {
  +        if( isIncluded() ) return;      // We are in an included sub-request
   	addHeader( CookieTools.getCookieHeaderName(cookie),
   			    CookieTools.getCookieHeaderValue(cookie));
   	if( cookie.getVersion() == 1 ) {
  @@ -442,7 +445,7 @@
   	    addHeader( CookieTools.getCookieHeaderName(c0),
   				CookieTools.getCookieHeaderValue(c0));
   	}
  -	if( notIncluded ) userCookies.addElement(cookie);
  +	userCookies.addElement(cookie);
       }
   
       public Enumeration getCookies() {
  @@ -462,7 +465,7 @@
       }
   
       public void setLocale(Locale locale) {
  -        if (locale == null || ! notIncluded) {
  +        if (locale == null || isIncluded() ) {
               return;  // throw an exception?
           }
   
  @@ -505,7 +508,7 @@
       }
   
       public void setContentType(String contentType) {
  -        if( ! notIncluded ) return;
  +        if( isIncluded() ) return;      // We are in an included sub-request
   	this.contentType = contentType;
   	String encoding = RequestUtil.getCharsetFromContentType(contentType);
           if (encoding != null) {
  @@ -519,7 +522,7 @@
       }
       
       public void setContentLength(int contentLength) {
  -        if( ! notIncluded ) return;
  +        if( isIncluded() ) return;      // We are in an included sub-request
   	this.contentLength = contentLength;
   	headers.putHeader("Content-Length", (new Integer(contentLength)).toString());
       }
  @@ -536,7 +539,7 @@
       /** Set the response status 
        */ 
       public void setStatus( int status ) {
  -	if( ! notIncluded ) return;
  +        if( isIncluded() ) return;      // We are in an included sub-request
   	this.status=status;
       }
   
  
  
  

Mime
View raw message