countUniq2.html
Author: Dan Bikle
This page allows me to count the number of unique visitors to another page.
If you want a session cookie put in your browser...
and if you want to get redirected to google.com...
and if you want your visit to google.com to be tallied for later display...
then,
click on this link:
http://google.com
The above link is not really a link to google.com.
The above link will take you to a servlet I wrote.
I named the servlet this: countUniq2.java
If you want to see the actual source code which makes up this servlet,
click on the link below:
countUniq2-java.txt
I placed a method named doGet() inside of countUniq2.java
doGet() does these things:
-It looks for a session cookie in your browser.
-If it does not find a session cookie, it does four things:
-It flags your session as a new session.
-It increments a counter to count you as a unique visitor to google.com
-It puts a session cookie in your browser.
-It sends you to google.com.
-If it does find a session cookie,
-It sends you to google.com.
If you want to count the number of unique visitors which have gone
to the above link through this page,
click on the button below.
The button below will call a doPost() method in the countUniq2.java servlet I wrote.
The doPost() method just sends some HTML to your browser with the value
of a counter variable embedded within the HTML.
Keep in mind that the servlet may not stay cached in the webserver's
JVM container for very long (if at all). In that case, the count
maintained by the servlet will get reset to 0. If you use Tomcat to
serve the servlet from your localhost, the servlet will stay cached
for a long time and the count will be more accurate.