|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A class can implement the ErrorHandler
interface when it
wishes to handle errors thrown by the method handler for the current
request. The Davenport servlet installs error handlers in a chain.
The first installed handler is invoked and given the chance to handle
the error/exception; if it rethrows the exception, the next installed
handler is invoked. If unhandled, the error is thrown from the servlet
and handled by the container.
To install a handler,
ErrorHandler
interface. The implementing class must also provide a no-arg
constructor.errorHandlers
parameter in the Davenport deployment descriptor. Entries are
separated by whitespace; the handlers are invoked in the order in which
they are declared in the descriptor.com.foo.MyErrorHandler
implementing smbdav.ErrorHandler
, you would add the following
to the Davenport deployment descriptor:
<init-param> <param-name>errorHandlers</param-name> <param-value>com.foo.MyErrorHandler</param-value> </init-param>
If no handlers are specified, Davenport installs instances of
smbdav.DefaultAuthErrorHandler
and
smbdav.DefaultIOErrorHandler
. If installing your own
handler, it may be desirable to include these as "fallback" handlers:
<init-param> <param-name>errorHandlers</param-name> <param-value>com.foo.MyErrorHandler smbdav.DefaultAuthErrorHandler smbdav.DefaultIOErrorHandler</param-value> </init-param>
Method Summary | |
void |
destroy()
Called by the Davenport servlet to indicate that the handler is being taken out of service. |
void |
handle(java.lang.Throwable throwable,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Called by the Davenport servlet to allow the error handler to process an error. |
void |
init(javax.servlet.ServletConfig config)
Called by the Davenport servlet to indicate that the handler is being placed into service. |
Method Detail |
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
Servlet
init
method; the method is called exactly once after
instantiation.
config
- a ServletConfig
object containing
the Davenport servlet's configuration and initialization parameters.
javax.servlet.ServletException
- If an error occurs during initialization.public void destroy()
Servlet
destroy
method. This method
gives the handler an opportunity to clean up any resources that
are being held. After this method has been called, the
handle
method will not be invoked again.
public void handle(java.lang.Throwable throwable, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Throwable
throwable
- The error that is being presented for handling.request
- The servlet request object.response
- The servlet response object.
java.lang.Throwable
- The presented error, if it cannot be processed
by this handler.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |