How to Display the Number of Server Hits in JSP
Using the JavaServer Pages Java programming language, Web developers can create dynamic websites. Tracking how many times your site has been visited allows you insight into whether anyone is going to your site and whether marketing campaigns are working to draw traffic. To display the number of server hits on your JSP site, you must insert the correct code into your site.
Instructions
-
-
1
Click “Start,” “All Programs” and select “Notepad.”
-
2
Click “File” and select “Open.” Select the JSP file and click “Open.”
-
-
3
Copy and paste the following code at the bottom of the JSP page between the “<body>” and “</body>” tags:
<%! Private int _iHitCount; %>
<CENTER>
<H1> Hit Count JSP</H1>
<P>Hits as of <%= new java.util.Data() %>: <%= ++_iHitCount %>
</CENTER> -
4
Click “File” and select “Save.”
-
5
Upload the saved JSP file to your Web server.
-
1