--- Casey Lucas <[EMAIL PROTECTED]> wrote:
>
> 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...
>
> 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.
>
Casey,
How about if you simply nest your try{
}catch(Throwable t){} inside the 'main' try..catch
block, do your cleanup and then throw it outwards to
be handled normally, like so:
public void _jspService(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// init jsp page stuff goes here
try {
try{
// body of JSP here ...
}catch(Throwable t){
//do tag pool cleanup here
throw t;
}
} catch (Exception e) {
out.clear();
pageContext.handlePageException(e);
} finally {
out.close();
factory.releasePageContext(pageContext);
}
}
Would that accomplish what you are trying to do? You
should be able to do this by modifying
JspParseEventListener's generateHeader() and
generateFooter() methods.
mel
> 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
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/