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

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
How to use 'continue' keyword in jsp page ? 
 

This is detailed java code that shows how to use 'continue' keyword in jsp page.

 

How to use 'continue' keyword in jsp page ?

                         

This is detailed java code that shows how to use 'continue' keyword in jsp page. The continue statement skips the remaining statements in the body of the loop for the current iteration, and continues with the next iteration of the  same loop. In this example, we have developed use_continue_statement.jsp page which shows the use of 'continue' keyword in JSP. This page asks the user to enter some value and loop in the JSP code shows the square of the number and for the next 4 numbers also.

Restriction with 'continue' statement : It can only be used within the body of a while, do, or for statement.

use_continue_statement.jsp

<HTML>
<HEAD>
<TITLE>use of 'continue' statement through jsp</TITLE>
</HEAD>
<BODY bgcolor="#6E6E6E">
<FORM NAME="form1" ACTION="use_continue_statement.jsp" METHOD="get">           
<table bgcolor="#D8D8D8">
<font color="#F8E0F7">You can calculate square of given number.</font>
<tr>
<td> Enter number </td>
<td><input type="text" name="num"></td>
</tr>
<tr align="center">
<td></td>
<td><INPUT TYPE="submit" VALUE="square"></td>
</table><br>
<table bgcolor="#F6E3CE" border="1" width="23%">
  <%
   /* check that value in text box is null or text box is empty */
   if (request.getParameter("num") != null && request.getParameter("num") != "") {
    int count = 0;
    // change the string value from textbox to a long type
    long num = Long.parseLong(request.getParameter("num"));
    %>
     <font color="#F8E0F7">You can see here a list of squared number</font>
      <%
       while (true) {
      %>
       <tr align="center">
         <td><Font>Square of  <%= num + count%></font></td>
           <td><%= ((num + count) * (num + count))%></td>
             </tr>
             <%
           count++;
	   if(count<5)
	   /* use continue statement to transfer control to the start of this loop */
            continue;
		else
            /* use break statement to transfer control out of this loop */
              break ;
                   }
               }%>
            </table>
        </FORM>
    </body> 
</html>

Save this code as a .jsp file named "use_continue_statement.jsp" in your application directory in tomcat server and run this jsp page with the following url in address bar of the browser  http://localhost:8080/user/use_continue_statement.jsp

When user enter integer value in appropriate text box and click square button.
For this example, suppose user enters value 25.

 Download source code

                         

» View all related tutorials
Related Tags: c com orm table ant data join select form make tables tab for to between e ul result pe from

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 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
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.