isErrorPage and errorPage attribute in JSP page directive

isErrorPage attribute:

This attribute is used specify that current jsp page can be used as an error page. It can have true or false value.

Syntax: <%@ page isErrorPage=”value”%> 

errorPage attribute:

This attribute is used to specify the URL of JSP page which is used as error page. An error page should have isErrorPage attribute true.

Syntax: <%@ page errorPage=”value”%>

Example:

welcome.jsp

<%@ page errorPage="errorPage.jsp" %>  
 
<html>
	<head>
	  <title>isErrorPage and errorPage page directive example</title>
	</head>
	<body>
		<%= 0/0 %>
	</body>
</html>

errorPage.jsp

<%@ page isErrorPage="true" %>  
 
<html>
	<head>
	  <title>isErrorPage and errorPage page directive example</title>
	</head>
	<body>
               	<h3>Hello this is an isErrorPage and 
                    errorPage page directive example.</h3>
		<br/>
		<h3>Some exception occurred.</h3>
		Exception: <%=exception %>
	</body>
</html>

web.xml

<web-app>
 
  <welcome-file-list>
          <welcome-file>welcome.jsp</welcome-file>
  </welcome-file-list>	
 
</web-app>

Output:

jsp example 11
 
Download this example.
 
Next Topic: isThreadSafe attribute in JSP page directive with example.
Previous Topic: contentType attribute in JSP page directive with example.

Related Topics:

import attribute of JSP page directive with example.
Session attribute of JSP page directive with example.
buffer attribute in JSP page directive with example.
autoFlush attribute in JSP page directive with example.
contentType attribute in JSP page directive with example.
isErrorPage and errorPage attribute in JSP page directive with example.
isThreadSafe attribute in JSP page directive with example.
language attribute in JSP page directive with example.
info attribute in JSP page directive with example.
JSP include directive with example.
JSP taglib directive with example.