JSP – ErrorPage Directive

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”%>

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>errorPage page directive example</title>
            </head>
            <body>
                        <h3>Some exception occurred.</h3>
                        Exception: <%=exception %>
            </body>
</html>
Scroll to Top