Home Jsp Simple-jsp-example Break Statement in JSP
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Break Statement in JSP

Advertisement
The use of break statement is to escape early from the loop. It allows the program to escape from the for, while, switch and do while loops.

Break Statement in JSP

        

The use of break statement is to escape early from the loop. It allows the program to escape from the for, while, switch and do while loops. A break may only appear on one of these statements. It is mainly used to escape early from the loop.

In this program we are using the switch statement under which we will use break statement. The for loop will run from 0 to 5. 

The code of the program is given below:

 

 

<html>
<head>
<TITLE> break Statement in jsp</TITLE>
  </HEAD>
 <BODY>
<table>
    <H1>break Statement in jsp</H1>
    <%
		for(int i =0; i <= 5; i++) {
		switch(i){
		case 0:
		out.println(i+ "is zero."+"<br>");
		break;
		case 1:
		out.println(i+ "is one."+"<br>");
		break;
		case 2:
		out.println(i +"is two."+"<br>");
		break;
		case 3:
		out.println(i+" is three."+"<br>");
		break;
		case 4:
		out.println(i+"is four."+"<br>");
		break;
		case 5:
		out.println(i+"is five."+"<br>");
		break;
		default:
			out.println(i+" is greater than 6");
		}
		}
%>
	</table>
  </BODY>
</HTML>

Output of the Program:

 

Download this example.

Advertisements

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 11, 2008

Ask Questions?    Discuss: Break Statement in JSP  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
kiran sidhu
July 24, 2013
computer

this is a good job for students who want to study with internet.
DMCA.com