Mel,
Thanks for the comments. See below.
Mel Martinez wrote:
>
> --- 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{
>
True. This is what I was hoping to do.
> // body of JSP here ...
>
> }catch(Throwable t){
> //do tag pool cleanup here
> throw t;
Can't do this because _jspService doesn't include Throwable
in it's throws clause... unless you make the additional modification
below.
> }
> } catch (Exception e) {
> out.clear();
> pageContext.handlePageException(e);
> } finally {
> out.close();
> factory.releasePageContext(pageContext);
> }
> }
Instead I was wondering if something like this is ok
(taken from my modified rendering) ? :
} catch (Exception ex) {
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (pageContext != null) pageContext.handlePageException(ex);
} catch (Throwable throwable) {
throw new org.apache.jasper.JasperException(throwable);
}
} finally {
if (out instanceof org.apache.jasper.runtime.JspWriterImpl) {
((org.apache.jasper.runtime.JspWriterImpl)out).flushBuffer();
}
if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
}
Will this mess up any error/exception propogation that you know of?
>
> 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/