Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Jsp Simple-jsp-example Try catch in JSP

Related Tutorials


 
 

Share on Google+Share on Google+

Try catch in JSP

Advertisement
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.

Try catch in JSP

        

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:

 

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

Discuss: Try catch in JSP   View All Comments

Post your Comment


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