Wednesday, November 26, 2014

Define Error page in Java web App



Page which will display the Error detail : ErrorPage.jsp

<%@ page isErrorPage=”true” %>
<html>
<body>
<strong>I am Error Page.</strong><br>
Error is : ${pageContext.exception}<br>
</body>
</html>

Page which will cause Error : Hello.jsp

<%@ page errorPage=”ErrorPage.jsp” %>
<html>
<body>
<%=1/0%>
</body>
</html>

Web.xml

<error-page>
          <error-code>404</error-code>
           <location>/jsp/ErrorPage.jsp</location>
</error-page>

<error-page>
          <error-code>java.lang.ArithMeticException</error-code>
           <location>/jsp/ErrorPage.jsp</location>
</error-page>

No comments:

Post a Comment

Scrum and Scrum master

Scrum  Scrum is a framework which helps a team to work together.  It is like a rugby team (the scrum name comes from rugby game). Scrum enco...