Mega Code Archive

 
Categories / Java Tutorial / JSP
 

Using a trycatch Block

< HTML>     <HEAD>         <TITLE>Using a try/catch Block</TITLE>     </HEAD>     <BODY>         <H1>Using a try/catch Block</H1>     <%         try{             int int1 = 1;             int1 = int1 / 0;             out.println("The answer is " + int1);         }         catch (Exception e){             out.println("An exception occurred: " + e.getMessage());         }     %>     </BODY> </HTML>