In this JavaEE JSP, we will setup an error page to display the exception messages using JSP Page Directives isErrorPage and ErrorPage.
1 2 3 4 5 6 |
01) Page Directive => Error Page <!-- //Sample 01: Set This a JSP Error Page --> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" isErrorPage="true" %> |
1 2 3 4 5 6 7 8 9 |
02) <!-- //Sample 02: Use exception object. --> <h3>Error Detected</h3> <h4>Reported Error is:</h4> <p> <% out.println(exception.getMessage()); %> </p> |
1 2 3 4 5 6 |
03) <!-- //Sample 03: Tell to redirect the Error to Error Page --> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" errorPage="ErrorPage.jsp" %> |
1 2 3 |
04) Throw Exception from First JSP. else throw new Exception("Name is not entered"); |
Categories: JSP