larryi      01/07/06 11:41:02

  Modified:    src/share/org/apache/tomcat/modules/generators
                        ErrorHandler.java
  Log:
  Fix recursive error handling if web.xml maps error code 404 to a non-existent
  JSP page. With this fix, no response will be sent if status handler is called
  recursively. You will need to examine the log output to see the error.
  
  If web.xml maps error code 404 to a non-existent html, use default "not found"
  handler instead of default "status" handler.
  
  Revision  Changes    Path
  1.14      +19 -3     
jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/ErrorHandler.java
  
  Index: ErrorHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/ErrorHandler.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ErrorHandler.java 2001/07/05 20:40:45     1.13
  +++ ErrorHandler.java 2001/07/06 18:41:00     1.14
  @@ -191,8 +191,15 @@
        }
   
        boolean isDefaultHandler = false;
  +        if ( statusLoop( ctx, req ) ){
  +            log( "Error loop for " + req + " error code " + code);
  +            return;
  +        }
        if( errorServlet==null ) {
  -         errorServlet=ctx.getServletByName( "tomcat.statusHandler");
  +            if( code == 404 )
  +                errorServlet=ctx.getServletByName( "tomcat.notFoundHandler");
  +            else
  +                errorServlet=ctx.getServletByName( "tomcat.statusHandler");
            isDefaultHandler = true;
        }
   
  @@ -389,9 +396,18 @@
        }
        return false;
       }
  -
  -
   
  +    /** Handle the case of status handler generating an error
  +     */
  +    private boolean statusLoop( Context ctx, Request req ) {
  +        if ( req.getAttribute("javax.servlet.error.status_code") != null ) {
  +            if( ctx.getDebug() > 0 )
  +                ctx.log( "Error: nested error inside status servlet " +
  +                        req.getAttribute("javax.servlet.error.status_code"));
  +            return true;
  +        }
  +        return false;
  +    }
       
   }
   
  
  
  

Reply via email to