You *might* be able to get away with this:

public void doFilter(...) {
  try {
    ...
    chain.doFilter(request, response);
    ...
  } catch(ServletException e){
     ...
     RequestDispatcher rd =
          request.getRequestDispatcher("/WEB-INF/moreCowbell.jsp");
     rd.forward(request,response);
  }
}

I think this should work if the chain.doFilter(request, response) does not commit the response.


An easier (but possibly less flexible) alternative exists in web.xml via an error-page declaration.
<!ELEMENT error-page ((error-code | exception-type), location)>
<error-page>
<error-code>404</error-code>
<location>/moreCowbell.jsp</location>
</error-page>



-Tim


Philipp Leusmann wrote:
Hi,

is it possible to catch thrown ServletExceptions through a filter to
generate a custom output?
Or, is there a way to define servlets which are processed if, for instance
an Error 500 is produced?

Thanks,
 Philipp



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to