In JSP, the errorPage attribute of page directive is used to specify a web page which will be displayed as an error page for the current JSP page
i.e. if there is an error while executing the current page).
Syntax
<%@ page errorPage= "path-to-another-jsp-page" %>
isErrorPage Attribute
In JSP, the isErrorPage attribute of page directive is used to specify whether the current page could be displayed as an error page for another JSP page.
We could set the value of isErrorPage to either true or false.
Syntax
<%@ page isErrorPage= "true|false" %>
isErrorPage = "true"
When isErrorPage is set to true, the current page is displayed in case an error appears in another JSP page.
<%@ page isErrorPage= "true" %>
isErrorPage = "false"
By default, the isErrorPage attribute value is false, hence we don't have to set isErrorPage to false,
in case if we don't want the current page to be displayed as an error appears for any JSP page.
Advertisement
errorPage and isErrorPage example
We are setting a web page ErrorPage.jsp as an error page for the current page StringLength.jsp
StringLength.jsp
<html>
<head>
<title>Calculate String Length</title>
</head>
<body>
<%
String str = null;
int length = str.length();
%>
Length of String is <%= length %>
</body>
</html>
executing the StringLength.jsp web page will throw an NullPointerException exception, which we read using JSP inbuilt exception object in ErrorPage.jsp.