We know that a website made by Java Web will inevitably have improper operations when users are using it, these improper operations may expose the path of the WEB Project (that is, the browser prompts errors such as 500 ). To prevent this situation and protect Java Web websites, we will write an error. jsp page in advance when designing a Java Web website. When an error occurs on the page, the error. jsp page is redirected to the page for processing, instead of the Error 500.
We need to do two things:
1. Error. jsp
<% @ Page contenttype = "text/html; charset = gb2312" Language = "Java" iserrorpage = "true" Import = "Java. io. * "%> <HTML>
Why is this page called error. jsp? It is because there is a parameter named iserrorpage = "true" in the second line. It clearly means whether the page is an error page.
2. What changes do other pages need to be made?
When a JSP page fails, how can it jump to the error. jsp page? The answer is to add the following tag to the header of the page (non-error. jsp:
<% @ Page contenttype = "text/html; charset = gb2312" Language = "Java" errorpage = "error. jsp" %>
We can see that there is an errorpage attribute. Set this attribute value to error. jsp.