Like we do in our JAVA system, we do have the lopping process which will be helpful in our proceeding learning’s.
Sample programs for the looping concepts are mentioned below:
IF Statement:
<html>
<head>
<title>If Else </title>
</head>
<body>
<%
int a = 5;
if(a > 0)
out.println("’a’ is greater than zero and has the value " + value );
%>
</body>
</html>
Output:

FOR Statement:
<html>
<head>
<title>For loop</title>
</head>
<body>
<%for (fontsize = 1 ; fontsize <= 3 ; fontsize++) { %>
<font color ="green" size ="<%= fontsize %>" >
Programming is Epic!!!
</font><br/>
<% } %>
</body>
</html>
Output:

WHILE Loop:
<html>
<head>
<title>While loop</title>
</head>
<body>
<%
int a = 5;
while (a > 0) {
out.println("The value of a in decrementing order " + a-- + ".<BR>");
}
%>
</body>
</html>
Output:

SWITCH Case Statements:
<head><title>Switch Case Statements</title></head>
<body>
<pre>
<script type="text/javascript">
// Switch statement with a numeric expression
var week_day = 4;
var day, open_hours;
switch (week_day) {
case 0:
day = "Sunday";
open_hours = "closed";
break;
case 1:
case 2:
case 3:
case 4:
case 5:
day = "a weekday";
open_hours = "open from 9:00am to 9:00pm";
break;
case 6:
day = "unknown";
open_hours = "open from 9:00am to 5:00pm";
break;
default:
day = "unknown"
open_hours = "undefined";
}
document.write('\n');
document.write("Today is " + day + ".\n");
document.write("The library is " + open_hours + ".\n");
</script>
</pre>
</body>
</html>
Output:
