As I started to add some code to remove pooled tag handlers from
the tag pool if an exception is thrown during tag usage, I came
across an issue...

In Tomcat 3, at the end of a JSP page, Jasper renders code to
catch java.lang.Exception. In Tomcat 4, Jasper renders code to
catch Throwable.  This is because of the spec diffs when it
comes to PageContext.handlePageException.

To clean up tag handlers in the case of exceptions, I need to
know when any exception is thrown.  So I figured the best way
to do this is to catch it. :) Yet in Tomcat 3, I can only safely catch
(and rethrow) java.lang.Exception, java.lang.Error, and
java.lang.RuntimeException.  If I simply added a catch for
java.lang.Throwable (like I wanted to), I can't correctly propagate
the exception under Tomcat 3.

I can ignore other Throwables (besides the three types mentioned)
but that means that tag handlers will not get removed from the pool
if a different type of exception is thrown. -- I don't really like it.

Alternatively, would it be ok to also catch Throwable at the bottom
of the rendered code (below the java.lang.Exception catch) then just
wrap it in a JasperException (or maybe just ServletException)?  If so,
I can do everything with just Throwables -- same model for Tomcat 3
and 4.  Would wrapping Throwables with JasperExceptions mess up any
error propagation from the JSP?

Thanks Jasper gurus.

-Casey

Reply via email to