Throwing an Exception

All methods use the throw statement to throw an exception. The throw statement requires a single argument a throwable object. Here is an example of a throw statement.

Throwing an Exception

        

All methods use the throw statement to throw an exception.  The throw statement requires a single argument a throwable object. Here is an example of a throw statement. 

The code of the program is given below:

<html>
    <head>
        <title>Throwing an Exception in jsp</title>
    </head>
        <body>
        <FONT SIZE="5" COLOR="#660066">Throwing an Exception in jsp<br></FONT>
        <%
        try {
            throw new ArrayIndexOutOfBoundsException
            ("Array index out of bounds Exception!");
        } catch(ArrayIndexOutOfBoundsException e) {
            out.println("<br><b>Exception message: </b>" + e);
        }
        %>
    </body>
</html>

Output of the Program:

Download this example.

Advertisements

Ads

 

We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.

Share on Google+Share on Google+

Throwing an Exception

Posted on: March 12, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: Throwing an Exception  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads