Home Jsp Simple-jsp-example Throwing an Exception
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Throwing an Exception

Advertisement
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

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 12, 2008

Related Tutorials

Ask Questions?    Discuss: Throwing an Exception  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com