Wednesday, February 10, 2010

jspprograms

First program of adding two numbers in JSP

< %@ page language="java"% >
< html >
< head >
< title > Add number program in JSP< /title >
< /head >

< body >
< %
int a=5;
int b=2;

int result=a+b;

out.print("Additon of a and b :"+result);
% >
< /body >
< /html >

Second program of subtraction two numbers in JSP

< %@ page language="java"% >
< html >
< head >
< title > Subtraction numbers program in JSP< /title >
< /head >

< body >
< %
int a=5;
int b=2;

int result=a-b;

out.print("Subtraction of a and b :"+result);
% >
< /body >
< /html >

Third program of print even numbers in JSP

< %@ page language="java"% >
< html >
< head >
< title > Even number program in JSP< /title >
< /head >

< body >
< %
for(int i=0;i< =10;i++)
{
if((i%2)==0)
{
out.print("Even number :"+i);
out.print("< br >");
}
}
% >
< /body >
< /html >

Forth program of print odd numbers in JSP

< %@ page language="java"% >
< html >
< head >
< title > Odd number program in JSP< /title >
< /head >

< body >
< %
for(int i=0;i< =10;i++)
{
if((i%2)!=0)
{
out.print("Odd number :"+i);
out.print("< br >");
}
}
% >
< /body >
< /html >

Bind Some Event to Element and trigger that function when click the element

Scenario: Suppose if we used same click event function in various web pages. if you want do some logic some page button for that need to re...