costin 01/09/13 22:02:03
Modified: src/share/org/apache/tomcat/modules/generators
ErrorHandler.java
Log:
Bug 3233, make error handling compatible with servlet2.3 by using the clarification
from
2.3 spec ( it wasn't technically a bug, since 2.2 leaves this part unspecified ).
Thanks [EMAIL PROTECTED] (Peter Stamfest) for the patch.
I did a small change for 3.3, since the ErrorHandler sits at a lower level and
doesn't
depend on the facade ( it is part of the set of core modules ). Since error handling
is
so dependent on the servlet api, in future we could move part of it in the facade,
but
for now it should be ok.
Submitted by: Peter Stamfest
Revision Changes Path
1.18 +23 -1
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.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ErrorHandler.java 2001/08/25 18:14:27 1.17
+++ ErrorHandler.java 2001/09/14 05:02:03 1.18
@@ -67,8 +67,8 @@
import java.net.*;
import java.util.*;
import java.security.*;
+import java.lang.reflect.*;
-
import org.apache.tomcat.util.log.*;
/**
@@ -299,6 +299,28 @@
String name = clazz.getName();
errorPath = ctx.getErrorPage(name);
clazz = clazz.getSuperclass();
+ }
+
+ // Bug 3233, [EMAIL PROTECTED] (Peter Stamfest)
+ if (errorPath == null ) {
+ // Use introspection - the error handler is at a lower level,
+ // doesn't depend on servlet api
+ Throwable t2=null;
+ try {
+ Method m=t.getClass().getMethod( "getRootCause", new Class[] {} );
+ t2 = (Throwable)m.invoke( t, new Object[] {} );
+ } catch(Exception ex) {
+ }
+
+ if (t2 != null) {
+ clazz = t2.getClass();
+ while (errorPath == null && clazz != null) {
+ String name = clazz.getName();
+ errorPath = ctx.getErrorPage(name);
+ clazz = clazz.getSuperclass();
+ }
+ }
+ if (errorPath != null) t = t2;
}
if( errorPath != null ) {