tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kin...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime PageContextImpl.java
Date Wed, 12 Dec 2001 01:19:35 GMT
kinman      01/12/11 17:19:35

  Modified:    jasper/src/share/org/apache/jasper/compiler JspReader.java
               jasper/src/share/org/apache/jasper/runtime
                        PageContextImpl.java
  Log:
  PR: 5345
  
  - This bug is caused by the recent change in response.sendRedirect in catalina
    that (correctly) enforces the rule that the response object is closed
    after a call to sendRedirect and subsequent write or flush throws an
    IllegalStateException.
  
    There is no real fix to this problem except by changing the semantics of
    sendRedirect in the Servlet spec to not to return after the call.  Since
    Jasper has no ideas that response.sendRedirect has been called, it cannot
    generate code to skip the rest of the page.
  
    Thus I take the position that it is an user error to include any text
    after the call to sendRedirect.  I did fixed the reader to ignore the
    extra '\n' that got generated automatically by the IO reader.
  
    I also put a check in PageContext.release not to flush the buffer
    if the response object has been close.  This would enable the user page
    to behave as expected, as long as the page is buffered, or the bufer
    size is not exceeded.
  
  Revision  Changes    Path
  1.7       +7 -1      jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspReader.java
  
  Index: JspReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspReader.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JspReader.java	2001/06/02 18:44:45	1.6
  +++ JspReader.java	2001/12/12 01:19:35	1.7
  @@ -332,7 +332,13 @@
       */
   
       public boolean hasMoreInput() throws ParseException {
  -	if (current.cursor >= current.stream.length) {
  +	// An extra '\n' seems to be inserted when there is none at end of
  +	// a file.  Not only is this useless, but it causes problems when
  +	// none is expected (e.g. after response.sendRedirect() ).
  +
  +	if (current.cursor >= current.stream.length ||
  +		((current.cursor == current.stream.length - 1) &&
  +			(peekChar() == '\n'))) {
               if (singleFile) return false; 
   	    while (popFile()) {
   		if (current.cursor < current.stream.length) return true;
  
  
  
  1.15      +14 -10    jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/PageContextImpl.java
  
  Index: PageContextImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/PageContextImpl.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- PageContextImpl.java	2001/12/05 00:19:18	1.14
  +++ PageContextImpl.java	2001/12/12 01:19:35	1.15
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/PageContextImpl.java,v
1.14 2001/12/05 00:19:18 kinman Exp $
  - * $Revision: 1.14 $
  - * $Date: 2001/12/05 00:19:18 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/PageContextImpl.java,v
1.15 2001/12/12 01:19:35 kinman Exp $
  + * $Revision: 1.15 $
  + * $Date: 2001/12/12 01:19:35 $
    *
    * ====================================================================
    *
  @@ -169,14 +169,18 @@
       }
   
       public void release() {
  -	try {
  -	    if (isIncluded) {
  -		((JspWriterImpl)out).flushBuffer(); // push it into the including jspWriter
  -	    } else {
  -		out.flush();
  +	// Flush the out stream only if the response is not committed.
  +	if (! response.isCommitted()) {
  +	    try {
  +	        if (isIncluded) {
  +		    ((JspWriterImpl)out).flushBuffer();
  +				// push it into the including jspWriter
  +	        } else {
  +		    out.flush();
  +	        }
  +	    } catch (IOException ex) {
  +	        loghelper.log("Internal error flushing the buffer in release()");
   	    }
  -	} catch (IOException ex) {
  -	    loghelper.log("Internal error flushing the buffer in release()");
   	}
   	servlet      = null;
   	config	     = null;
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message