Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions? | Software Development
 

Multiple try catch

The code which can throw exception should be written in the try block. If the exceptions occurs at that particular block then it will be catch by the catch block. We can have more than one try/catch block.

Multiple try catch

                          

The code which can throw exception should be written in the try block.  If the exceptions occurs at that particular block then it will be catch by the catch block. We can have more than one try/catch block. The most specific exception which can be thrown is written on the top in the catch block following by the less specific least. 

 

The code of the program is given program:  

 

 

 

<HTML>
    <HEAD>
        <TITLE>Multiple try/catch in Jsp</TITLE>
    </HEAD>
    <BODY>
		<FONT SIZE="6" COLOR="#CC3300">Multiple try/catch in Jsp</FONT><br>
    <%
    try {
        int a[] =new int[6];
		for(int i = 0; i<7; i++){
		
		 a[i]=i;
		}
    } catch (ArrayIndexOutOfBoundsException e) {
        out.println("Array index out of bounds.");
    } catch(ArithmeticException e) {
        out.println("Arithmetic exception: " + e);
    } catch(Exception e) {
        out.println("An error occurred: " + e);
    }
    %>
    </BODY>
</HTML>

Output of the Program:

 

Download this example.

                          

» View all related tutorials
Related Tags: java c library error ide io vi core tag lock this id action block write invoke like handle if solution

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
 
Tell A Friend
Your Friend Name

 

 
Recently Viewed
Software Solutions
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.