Home Jsp Simple-jsp-example Break Statement in JSP



Break Statement in JSP
Posted on: March 11, 2008 at 12:00 AM
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.

Related Tags for Break Statement in JSP:
cooploopssedloopescapestateusingthisaipearooappforprogramstatementwhiletobreakramrunwseareilmainitusepefrominstamntpsswitchcaoopsesemallmeproppstatementsdowhichsatkislleaearlyandarstatscassthswstapprndonlyonomogronl


More Tutorials from this section

Ask Questions?    Discuss: Break Statement in JSP  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

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.