My Java web app currently maps certain error codes to an error servlet (spring web flow, actually, but that should be besides 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 certain cases the server will still crash and give a stack trace dump of some exceptions to the user. (Running on IBM WebSphere btw). My question then is; is it possible to define a fall-back error page that will be used if all other errors don't match? So that we're guaranteed not to end up with a stack trace under any circumstance.
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 more info.