If you are using a Servlet 3.0 container such as Tomcat 7.0, you can simply omit the <error-code> (or <exception-type> ) element to make it the default global error page.
<error-page> <location>/string_error.jsp</location> </error-page>
Since Servlet 3.0, these elements are optional.
However, if you are not already on Servlet 3.0, you will have to configure it at the container level. For example, Tomcat 6.0 (which is a Servlet 2.5 container), you need to create your own error reporting valve class. You can then specify it as the errorReportValveClass attribute of the <Host> element in the /conf/server.xml file.
For other containers, refer to their documentation.
source share