How to determine the common / error page error in web.xml

Currently, the Java Java web application maps specific error codes to the error servlet (spring web stream, actually, but this should be beyond the point) by doing this in web.xml:

<error-page> <error-code>500</error-code> <location>/spring/error?error=500</location> </error-page> <error-page> <error-code>404</error-code> <location>/spring/error?error=404</location> </error-page> 

However, in some cases, the server will still crash and provide a stack trace dump of some exceptions to the user. (Works in IBM WebSphere btw). Then my question is; is it possible to determine the return error page to be used if all other errors do not match? So we guarantee that under any circumstances we won’t get a stack trace.

+7
source share
1 answer

Use the following:

 <error-page> <exception-type>java.lang.Throwable</exception-type> <location>/error.jsp</location> </error-page> 

See http://www.oracle.com/technology/sample_code/tech/java/codesnippet/servlets/HandlingServletExceptions/HandlingServletExceptions.html for details.

+12
source

All Articles