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

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
Use Break Statement in jsp code 
 

in this section, you will read how to use of break statement in jsp.

 

Use Break Statement in jsp code

                         

The break statement is used to terminate the execution of near most enclosing loop or conditional statement. Now the next statement outside the loop is executed.

In the example given below the elements of an array are added one by one. After each addition, the sum is checked whether it is more than 12. If the sum is less than 12 then the message "we are in loop..." is displayed otherwise the control comes out of the loop and does not print the same line again for this iteration. The rest iterations are also not executed because the loop is now terminated and the control is on the next statement after loop.

break_statement_jsp.jsp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
<HTML>
  <HEAD>
    <TITLE>Using the break Statement</TITLE>
  </HEAD>
  <BODY>
    <H1>use break statement in jsp code</H1>
    <%
        double array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        int sum = 0;
        for(int i = 0; i < array.length; i++) {
            sum += array[i];
	    // use break statement.
            if (sum > 12) break;
            out.println("we are in loop...<BR>");
        }
        out.println("The sum exceeded the max allowed value 12.");
    %>
  </BODY>
</HTML>

Save this code as a jsp file named "break_statement_jsp.jsp" in your application directory (user, for this example) in Tomcat and run this jsp page with http://localhost:8080/user/break_statement_jsp.jsp url in address bar of the browser.

Download Source Code

                         

» View all related tutorials
Related Tags: java c exception class control io multiple find ip exec lock state int block exe row with matching match statement

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 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

I like your way of teaching.I learned java concepts through your online teaching.
thanks for your service.

Posted by francis on Tuesday, 09.23.08 @ 19:33pm | #80639

Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
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

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

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

Copyright © 2008. All rights reserved.