In try block we write those code which can throw exception while code execution and when the exception is thrown it is caught inside the catch block. The try catch block in jsp just work as try catch block in the java.
The code of the program is given below:
<HTML>
<HEAD>
<TITLE> Use of Try catch in jsp</TITLE>
</HEAD>
<BODY>
<table align="center" bgcolor="#E1E1FF" border="1">
<H1>Use of Try catch in jsp</H1>
<%
try{
int a = 10;
int b = 10;
b = a / 0;
}
catch(Exception e){
out.println("The Error is: " + e);
}
%>
</table>
</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: Try catch in JSP View All Comments
Post your Comment