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:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Throwing an Exception
Post your Comment