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.
The syntax error is identified by the parser. When it is been identified it generates XML Exception with the certain information which is given below: To handle the errors efficiently processing steps should be taken with the parser statement and special register as well. XML_CODE has numeric exception codes.
Error page tag: This tag is used to specify the error occurred in the while weblogic server is responding ti a HTTP request, returns an HTML page that displays either the HTTP error code. In the above example error-page tag specify the error code as 105 and location describes the location of the jsp page.
In your own error handling page, you can hide the technical information by showing only readable message to the user. For example, here’s the HTML code of the Error404.jsp page: You can add other <error-page> elements to handle other error codes. For example, the following XML snippet declares the page that handles the HTTP 500 error:
If the request is handled by a Web application running in WebSphere Application Server, and an error occurs, use the error-page option in web.xml (or web_merged.xml if it exists) to specify a customized error page. For more details, see the Information Center topic Web.xml.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With