Metawerx Java Hosting Small Logo

<exception-type>

The exception-type element gives the fully qualified name (eg. both package and class) of an Exception or Throwable.

Whenever the webapp throws an Exception matching the exception-type, the user will be redirected to the page given by the location element.

The exception-type element can be as specific (java.lang.NullPointerException) or as general (java.lang.Throwable) as required.

Example for catching all Exceptions and Errors thrown by the application

<!-- Define an error handler for all Exceptions and Errors --> 
<error-page> 
    <exception-type>java.lang.Throwable</exception-type> 
    <location>/generalError.jsp</location> 
</error-page>

Notes

  • Handling of exceptions takes precedance over handling of error codes. ie: if an exception is thrown, and available, it will be passed to the exception handler. If no <exception-type> handler is present, a 500/503 error code is generated, and that will be passed to the handler specified by the <error-code> directive. If no <error-code> directive is specified, the 500/503 error will be returned to the browser.
  • Certain errors such as Struts "No action instance for path /somePath could be created" errors only return a 500 error code. They do not throw a Throwable. It is therefore good practise to catch 500 errors as well as Throwables.

See Also

navigation
metawerx specific
search
Share
tools
help

referring pages

Share