Errors occur during the execution of a web application. Errors can be throwed by Servlet or JSP. When an error occurs , we can display the srror in a specifc error screen (Page) . That means we can map the error code returned by HTTP response or a Java Language exception returned by any web component to any page (Html or Jsp) .
This mapping is done by the
<error-page>
<error-code>404</error-code>
<location>/filenotfound.jsp</location>
</error-page>
<error-page>
<error-code>400</error-code>
<location>/badrequest.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.ClassNotFoundException</exception-type>
<location>/classnotfound.jsp</location>
</error-page>
<error-page>
<exception-type>javax.servlet.jsp.JspException</exception-type>
<location>/jspexcept.jsp</location>
</error-page>
If you need to use a different error page for some specific JSP pages (for example register.jsp) , you can use the page directive's errorPage attribute to override the web.xml declaration in those pages.
register.jsp
-------------
<%@ page language="java" contentType="text/html" errorPage="jspError.jsp" %>
if any error occurs in the register.jsp, then the jspError.jsp will be called instead of mapping error codes defined in Web.xml
0 comments:
Post a Comment