In this example we will define that about page counter every time a user visit the page will be counted. In this we made a program where i static click variable initialize and the value declare 0. If any user visit site any tym it will display the visit number. With help of for loop it will increase the visits one by one.
<html>
<head>
<title><Jsp Page Counter></title>
</head>
<body bgcolor=”#F8E4E4″>
<%!static int click=0; %>
<%
if (click == 0)
{
%>
<br><h3 align=”center”><% click ++;
out.println(“Welcome To Java Server Page Counter”); %> </br>
<% out.println(“Visitor Number : “);%> <%=click %>.</h3>
<%
click++;
}
else
{
%>
<br><h3 align=”center”><% out.print(“Welcome…!”);%></br>
<h3 align=”center”><% out.print(“You are Visitor Number : “);%> <%=click %>.</h3>
<%
click++;
}
%>
</body>
</html>