Original translated from: http://www.diybl.com/course/3_program/java/javajs/20071111/85327.html
Step 1: Create a JSP page that displays error information. The content is as follows:
<% @ page Language = "Java" contenttype = "text/html; charset = UTF-8 "pageencoding =" UTF-8 "iserrorpage =" true "%>
<% @ taglib uri =" http://java.sun.com/jsp/jstl/core "prefix =" C "%>
system execution error
system execution an error occurred, the information is described as follows:
error status Code : $ {pagecontext. errordata. statuscode }
error page: $ {pagecontext. errordata. requesturi}
error message: $ {pagecontext. exception}
error stack information:
$ {trace}
Of course, this is only used to Display Error-related information, which contains the vast majority of Error-related information. You can use this information to customize your error display.
Step 2: configure the Web. xml file and add an error page.
<Error-page>
<Exception-type> JAVA. Lang. Exception </exception-type>
<Location>/error. jsp </location>
</Error-page>
This configuration indicates that if an exception of the Java. Lang. Exception type (including subclass) occurs on the JSP page or servlet, it will be forwarded to the error. jsp page for processing.
<Error-page>
<Error-code> 500 </error-code>
<Location>/error. jsp </location>
</Error-page>
This configuration is also possible, indicating that when a 500 error occurs, it is transferred to the error. jsp page for processing.
Is it easy? You can configure multiple <error-page> sections to forward different types of errors to different error handling pages. The methods are available, configure your personalized error message display.