by Dinesh Thakur Category: JSP Elements

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>&lt;Jsp Page Counter&gt;</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>         

       jsp pageCount Example

 

       jsp pageCount Example               



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.