Throwing an Exception

Ads
 

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.

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.

Ads

Ads