Thanks a lot for the answers. But, it is still not working for me. I tried in IE as well as in Google Chrome. This is my code....
web.xml
================================================================
<?xml.... >
<servlet> ... </servlet>
<servlet-mapping> ... </servlet-mapping>
<error-page>
<error-code>404</error-code>
<location>/PageNotFoundErrors.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.ArithmeticException</exception-type>
<location>/ArithmeticErrors.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/OtherErrors.jsp</location>
</error-page>
</web-app>
jsp page:
====================================================================================
<body>
<%!
public void recursion() // This function calls itself countless times and finally produces a StackOverflowError
{
recursion();
}
%>
Enter 1 for ArithmeticException, 2 for 'Page not found', 3 for 'Other errors'... <br />
<form method = "POST">
<input type = "text" name = "option" />
<br /><br />
<input type = "submit" />
</form>
<c:if
test = "${pageContext.request.method == 'POST'}">
<c:choose>
<c:when test = "${param.option == '1'}" >
<% int i = 10%0; // This code generates an ArithmeticException %>
</c:when>
<c:when test = "${param.option == '2'}" >
<c:redirect url = "/NonExistentPage.jsp" />
</c:when>
<c:when test = "${param.option == '3'}">
<% recursion(); %>
</c:when>
<c:otherwise>
<c:out value = "There are no errors..." />
</c:otherwise>
</c:choose>
</c:if>
</body>
=================================================================================
Everytime I run this, no matter what error is generated, I am always redirected to OtherErrors.jsp
What can be the solution?