larryi 01/07/06 11:40:08
Modified: src/share/org/apache/tomcat/core Tag: tomcat_32
ContextManager.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
No revision
No revision
1.100.2.24 +22 -2
jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
Index: ContextManager.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
retrieving revision 1.100.2.23
retrieving revision 1.100.2.24
diff -u -r1.100.2.23 -r1.100.2.24
--- ContextManager.java 2001/04/25 16:50:12 1.100.2.23
+++ ContextManager.java 2001/07/06 18:40:05 1.100.2.24
@@ -1047,8 +1047,16 @@
if( debug>0 )
ctx.log( "Handler " + errorServlet + " " + errorPath);
- if( errorServlet==null )
- errorServlet=ctx.getServletByName( "tomcat.statusHandler");
+ if ( statusLoop( ctx, req ) ){
+ log( "Error loop for " + req + " error code " + code);
+ return;
+ }
+ if( errorServlet==null ) {
+ if( code == 404 )
+ errorServlet=ctx.getServletByName( "tomcat.notFoundHandler");
+ else
+ errorServlet=ctx.getServletByName( "tomcat.statusHandler");
+ }
req.setAttribute("javax.servlet.error.status_code",new Integer( code));
@@ -1194,6 +1202,18 @@
return true;
}
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;
}
/**