"JSP" Configuration error page

Source: Internet
Author: User

1, using JSP mode

If the configuration is JSP, you need to set Iserrorpage to True,

and set <%@ page language= "Java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "iserrorpage=" true "%>

Error page:

<% @pageImport= "Java.io.PrintStream"%> <% @pageImport= "Java.io.ByteArrayOutputStream"%> <%@ include file= "web-inf/views/includes/tags.jsp"%> <%@ page Language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding= "UTF-8" iserrorpage= "true"%> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" > class= "Ui-alert-panel" > //Output exception information hereException.printstacktrace (); Bytearrayoutputstream Ostr=NewBytearrayoutputstream (); Exception.printstacktrace (NewPrintStream (OSTR));    Out.print (OSTR); %> </div> </body> errorpage.jsp

You can use this page to trigger the error above:

<!--     --><%@ page language= "java" contenttype= "text/html; charset=utf-8"    pageencoding = "UTF-8" errorpage= "errorpage.jsp"%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >         NULL ;        A.tostring (); // make a mistake    %></body>
home.jsp

2, you can also use the configuration XML method:

<?xml version= "1.0" encoding= "UTF-8"? ><web-app xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns= "Http://java.sun.com/xml/ns/javaee" xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee/http Java.sun.com/xml/ns/javaee/web-app_3_0.xsd "version=" 3.0 "> <display-name>day06_jspdemo1</ display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> </ Welcome-file-list> <!--exception state handling for a project-<!--default error Handling page--<error-page> <error-code>403</error-code> <location>/403.html</location> </error-page> <error-page> & Lt;error-code>404</error-code> <location>/404.html</location> &LT;/ERROR-PAGE&G          T <!--just look at debugging and not comment-<!--in a formal deployment, which means that the 500 error occurs when you go to 500.jsp page processing. -<error-page> <error-code>500</error-code> &LT;LOCATION&GT;/5 00.html</location> </error-page> <!--This configuration means that if a JSP page or servlet occurs JAVA.LANG.EXCE Exceptions to the Ption type (which of course contain subclasses) go to 500.jsp page processing.               -<error-page> <exception-type>java.lang.Exception</exception-type>          <location>/500.jsp</location> </error-page> <error-page>     <exception-type>java.lang.Throwable</exception-type> <location>/500.jsp</location&           Gt </error-page> <!--when errorWhen both-code and Exception-type are configured, the exception-the type is configured with a high page priority and a 500 error, which jumps to 500.jsp when an exception occurs exception-</web-app>
Web. XML

Error pages can also be written on their own, we can also introduce public welfare 404 pages, such as:

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "    pageencoding=" UTF-8 "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >// This setting can cheat IE browser, let IE browser successfully display public welfare 404 page         response.setstatus ($);     %></body>
500.jsp

Original link: web. XML Configuration Error page

"JSP" Configuration error page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.