craigmcc    00/11/09 18:06:32

  Modified:    src/share/org/apache/tomcat/core Tag: tomcat_32 Handler.java
  Log:
  Restore the previous exception propogation model so that exceptions are
  propogated only from included servlets.  This undoes part of a change
  Larry committed earlier -- after further discussion with him, we've agreed
  that this is the correct behavior so that servlets can trap exceptions
  thrown by included servlets without corrupting the content of the
  response.
  
  NOTE:  If you include a JSP page that declares an error page, and your JSP
  page throws an exception, the transfer to the error page will still happen
  as expected even in an included page.  This is handled completely within
  the JSP environment, and did not rely on the error propogation mechanism
  for servlet exceptions -- which was Larry's primary concern.
  
  As a result of this change, Tomcat 3.2 will trigger the <error-page>
  handling only if the top-level servlet throws an exception.  This is also
  consistent with the behavior of Tomcat 4.0 in this respect.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.7.2.6   +27 -21    jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java
  
  Index: Handler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java,v
  retrieving revision 1.7.2.5
  retrieving revision 1.7.2.6
  diff -u -r1.7.2.5 -r1.7.2.6
  --- Handler.java      2000/11/09 14:11:27     1.7.2.5
  +++ Handler.java      2000/11/10 02:06:32     1.7.2.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java,v 1.7.2.5 
2000/11/09 14:11:27 larryi Exp $
  - * $Revision: 1.7.2.5 $
  - * $Date: 2000/11/09 14:11:27 $
  + * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java,v 1.7.2.6 
2000/11/10 02:06:32 craigmcc Exp $
  + * $Revision: 1.7.2.6 $
  + * $Date: 2000/11/10 02:06:32 $
    *
    * ====================================================================
    *
  @@ -258,16 +258,19 @@
                    contextM.handleStatus( req, res, 404);
                    return;
                }
  -             // handle error, does nothing if already handled
  -             contextM.handleError( req, res, ex);
  -             // rethrow the exception
                context.log("Exception in init  " + ex.getMessage(), ex );
  -             if (ex instanceof IOException)
  -                 throw (IOException) ex;
  -             else if (ex instanceof ServletException)
  -                 throw (ServletException) ex;
  -             else
  -                 throw new ServletException("Servlet Init Exception", ex);
  +                if (res.isIncluded()) { // Only propogate on includes
  +                    if (ex instanceof IOException)
  +                        throw (IOException) ex;
  +                    else if (ex instanceof ServletException)
  +                        throw (ServletException) ex;
  +                    else
  +                        throw new ServletException
  +                            ("Servlet Init Exception", ex);
  +                } else {                // Only handle on top level
  +                    contextM.handleError( req, res, ex );
  +                    return;
  +                }
            }
        }
          }
  @@ -289,17 +292,20 @@
   
        if( t==null ) return;
   
  -     // handle error, does nothing if already handled
  +        // Rethrow the exception if we are inside an include
  +        if (res.isIncluded()) {
  +            //            context.log("Rethrowing doService exception: " + t);
  +            if (t instanceof IOException)
  +                throw (IOException) t;
  +            else if (t instanceof ServletException)
  +                throw (ServletException) t;
  +            else
  +                throw new ServletException("Servlet Exception", t);
  +        }
  +
  +     // handle error, does nothing if already handled, at top level
        contextM.handleError( req, res, t );
   
  -     // rethrow the exception
  -     context.log("Rethrowing doService exception: " + t);
  -     if (t instanceof IOException)
  -         throw (IOException) t;
  -     else if (t instanceof ServletException)
  -         throw (ServletException) t;
  -     else
  -         throw new ServletException("Servlet Exception", t);
       }
   
   //     protected void handleError( Request req, Response res, Throwable t) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to