Would it be possible to change the generated _jspService() method to catch
Throwable instead of Exception?  JSP 1.2 is taking this direction (excerpt
and patch below).

Without breaking the existing JSP 1.1 implementation, the existing
catch(Exception) block in _jspService() can be modified to take a Throwable
or an additional catch(Throwable) block defined.  When a Throwable (that is
not an Exception) is caught, it can be wrapped with an
InvocationTargetException or TomcatException (or some other Throwable
wrapper Exception).  This allows PageContext.handlePageException(Exception)
to continue to be used IAW the 1.1 spec.

This is helpful for obvious reasons.  In our case, we had a RuntimeException
being thrown from a static initializer which was being caught by the
ClassLoader and thrown as a ExceptionInInitializerError.

--robs

--------------------------------------------------------------

>From the JSP 1.2 spec description of PageContext (para 9.2.1):

* public abstract void handlePageException(java.lang.Exception e)

...

This method is kept for backwards compatiblity reasons. Newly generated code
should use PageContext.handlePageException(Throwable).


* public abstract void handlePageException(java.lang.Throwable t)

This method is identical to the handlePageException(Exception), except that
it accepts
a Throwable. This is the preferred method to use as it allows proper
implementation of
the errorpage semantics.

...

--------------------------------------------------------------

Here's a rudimentary patch that got us what we were looking for..

src/share/org/apache/jasper/compiler/JspParseEventListener.java

diff -u -r1.1 JspParseEventListener.java
--- JspParseEventListener.java  2000-11-22 10:09:42-05  1.1
+++ JspParseEventListener.java  2000-11-22 10:08:22-05
@@ -345,13 +345,14 @@

     private void generateFooter() throws JasperException {
        writer.popIndent();
-       //writer.println("} catch (Throwable t) {");
-       writer.println("} catch (Exception ex) {");
+       writer.println("} catch (Throwable t) {");
+       //writer.println("} catch (Exception ex) {");
        writer.pushIndent();
         writer.println("if (out.getBufferSize() != 0)");
         writer.pushIndent();
        writer.println("out.clearBuffer();");
        writer.popIndent();
+       writer.println("java.lang.reflect.InvocationTargetException ex = new
java.lang.reflect.InvocationTargetException(t);");
        writer.println("pageContext.handlePageException(ex);");
        writer.popIndent();
        writer.println("} finally {");

Reply via email to