This discussion is archived
3 Replies Latest reply: Dec 10, 2012 9:51 PM by Kayaman RSS

Not able to handle the exception in web application

955481 Newbie
Currently Being Moderated
In my web application i m trying to handle the run time exception with the help of <exception-type> and <location> tag in web.xml file as show below.

But whille running the application the exeception raised when n>5 is not handled and i am getting internal server error with root cause as " coreservlets.DumbDeveloperException: Value of n is greater than 5 ".

I have kept all the files in the proper path and directory and i am using Tomcat 7.0.27.

Kindly help me how to sort it out.

<web-app version="3.0" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
the other files of my web applications are given below.
package coreservlets;

public class DumbDeveloperException extends Exception {
  public DumbDeveloperException() {
    super("Value of n is greater than 5");

  public static int dangerousComputation(int n)
      throws DumbDeveloperException {
    if (n < 5) {
      return(n + 10);
    } else {
      throw(new DumbDeveloperException());
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HEAD><TITLE>Risky JSP Page</TITLE></HEAD>
       <h2>Risky Calculations </h2>
        <%@ page import="coreservlets.*" %>
        <% int n = ((int) (10 * Math.random()));%>
            <LI>n: <%= n%>
            <LI>dangerousComputation(n): <%= DumbDeveloperException.dangerousComputation(n)%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
        <H2>Dumb Developer</H2>
        We're brain dead. Consider using our competitors.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points