tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Isaacs <>
Subject RE: Handler/ServletWrapper/Error handling
Date Sun, 10 Dec 2000 01:16:04 GMT

> Easy to do, seems a good idea. What about adding handleInitException()
> and
> handleServiceException() - since a ClassNotFound will have different
> effects ( 404 if in init, normal error if in service - the first means
> the
> servlet wasn't found, the second may happen if the servlet does a
> Class.forName with a class that is not found ). 


> There is another hook I want to add, preInit() - that can be called
> before 
> preServletInit / init / postServletInit. It'll be used to prepare the
> handler for preServletInit ( i.e. loadServlet, check if still
> unavailable). That would make a very clean implementation of
> unavailable,
> and avoid calling pre/post too often. 


> 1. We can move ErrorHandler after Servlet22EH ( or just replace it ).

Since default error output now only occurs at the top level request, my desire was to have
a "notFoundHandler" that could show the "included"
request URI if that was where the "not found" occurred.  (Handy during development.)

With EH after Servlet22EH, EH is going to call ctx.addErrorPage("404",...)
after Servlet22EH, replacing the enhanced handler with the default one.
If we put EH before ServletEH, then EH's handleError() gets called
first.  Though it will find Servlet22EH's handler for "404", other things
may not work right. :-(

> 2. We can enhance the code to do what Apache2.0 does - accept a FIRST,
> BEGGINING, END, LAST options for the hooks. That's the best solution,
> but
> it's a bit complex ( and I would leave it at the end, after we finish
> everything else in core / bug fixes / etc.). 

I still think there might be a case for saying that the nature of a
interceptor method implies whether a new instance is appended or
inserted at the beginning.  I haven't spent much time looking at the
issue, but at this moment, contextInit() looks to me like an "append"
(interceptors added later are called later) and handleError() looks like
an "insert at beginning" (interceptors added later are called earlier).
With this, the placing the "overrider" after the "overridee" will work and you can override
error handlers all you want.  With just FIRST,
BEGINNING, END, LAST, once an interceptor uses one, you limit what
another "overriding" interceptor can use and still work.

> BTW, what about a more radical aproach - just remove init/destroy from
> handler, leave only service() ( eventually renamed to "invoke" :-) ?
> The whole init/destroy machine is servlet-specific - none of the
> internal
> handlers are using it and the modules have access to all the Interceptor
> notifications anyway. 

This appeals to me too. +1


View raw message