
Iteration
Program:-
<html>
<head>
<title>use of forloop in
jsp</title>
</head>
<body>
<h1>this is my second jsp
program</h1>
<%
for(int i=0;i<10;i++)
{
out.println("iteration"+i+"<br>");
}
%>
</body>
</html>
Output:-
Program to display date:-
<html>
<head>
<title>show
date</title>
</head>
<body>
<h1>this is my first jsp
program</h1>
<p>
Todaysdate:<%=new
java.util.Date()%>
</p>
</body>
</html>
Output:-
Addition
Two No.:-
<html>
<head>
<title>adding two no. in
jsp</title>
</head>
<body>
<h1>this is my third jsp
program</h1>
<%
int
a=5;
int
b=2;
int
result=a+b;
out.println("addition"+result);
%>
</body>
</html>
Otput:-
Even
Program:-
<html>
<head>
<title>even no. in
jsp</title>
</head>
<body>
<h1>my even no.
program</h1>
<%
for(int i=1;i<=10;i++)
{
if(i%2==0)
{
out.println("even
no."+i+"<br>");
}
}
%>
</body>
</html>
Output:-
Odd
Program:-
<html>
<head>
<title>even no. in
jsp</title>
</head>
<body>
<h1>my even no.
program</h1>
<%
for(int i=1;i<=10;i++)
{
if(i%2!=0)
{
out.println("even
no."+i+"<br>");
}
}
%>
</body>
</html>
Output:-
0 Comments