JSP error page does not jump to display 500

Source: Internet
Author: User

Problem Description: Use page jump to prompt the page error message, but the program failed to run, and did not jump to the error page.

The two pieces of code are as follows:

First paragraph (error.jsp):

<!--jump to the error page when an error occurs in this file when an error occurs, it jumps to error.jsp--

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
pageencoding= "UTF-8" errorpage= "error.jsp"%>


<%
int i = 10/0;//produces an exception
%>

Second paragraph (iserror.jsp):

<!--errorshow_demo.jsp File error when you jump to this page--
<%@ page language= "java" contenttype= "text/html" pageencoding= "Utf-8"%>
<!--means this page can handle errors--
<%@ page iserrorpage= "true"%>

Cause: Tomcat will iserror.jsp also think that an error has occurred, so it cannot be displayed.

Workaround: Add the following code snippet in iserror.jsp:

<%
Response.setstatus (200);//Status code can be selected 200-203
%>

Manually set a status code, indicating that there is no error on this page, can be displayed normally.

JSP error page does not jump to display 500

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.