Java Glossary : hit counters

CMP home Java glossary home Menu no menu Last updated 2004-06-28 by Roedy Green ©1996-2004 Canadian Mind Products

Java definitions: 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

You are here : home : Java Glossary : H words : hit counters.

hit counters
One of the most commonly requested Applets is one that will display the number of visitors to a page like this: The hit counter above is done with Novell SSI. The problem with it is the hit counter is incremented every time the hit counter is displayed, not every time the corresponding file is downloaded. If you display the counter in more than one place, or other than in the file being monitored, you will get inaccurate results.

Unfortunately, it is not possible to write such a program in Java without the co-operation of a server somewhere to centrally record the current value of the counter.

Happily there are people who will provide you with free hit counters and free use of their server, usually in exchange for some advertising on the counter.

A source of free counters is TheCounter.com. They require 24 lines! of Javascript that confounds the Vslick beautifier. The odd thing is, to me, it looks as if the JavaScript is unnecessary. By default, the counters look like this:

TC

Another source of free counters is honesty.com. These counters use CGI and so do not require JavaScript-enabled browsers. The look of the counters is configurable, but by default they look like this:

hit_counter

You can get a commercial, advertising-free hit counter, including use of the counting server, for about $35.00 USD to $600.00 USD a year, depending on number of hits. Try the WebCounter people. They also issue free counters that by default look like this:

counter

Commercial hit counters generally give faster response than free ones. Before you sign up see if you can find some of that vendor's hit counters on other people's sites and see how responsive they are. A sluggish hit counter can be very annoying to your visitors.

Some hit counters let you substitute your own set of ten gifs for the digits 0 to 9 to create the counter. With search engines, you can find hundreds of sets of free gifs to use.

There is not much point combing the web for hit counter software to run on your server. Most ISPs won't let you run it. They may have some software they have tested they will let you run, usually for a fee. The hit counters on my pages are handled by Novell's SSI and are sent as ASCII text. Every ISP will have his own preferred way of doing them, usually with CGI.

In theory, you could create a Java Applet to display a hit counter. The central site could send the value of the count over in compact binary. However, this would be slower than using CGI since tche browser would need to download the Java Applet containing contain code and a complete set of GIFs for all the digits. Further the browser user would need to load the Java interpreter. This would take considerably more time than just sending the count or the gifs needed to display the current count. The other problem is the count would not work for people who did not have Java installed or if their Java did not work, or if the Java Plug-In 1.2 had sabotaged the 1.1 version. If there were some way of caching Applets, this technique could be very fast. Perhaps we will see them in future, using smoooth animations or other gimickry.

There are several possible ways of computing hits.

CGI ¤ echo server ¤ gostats.com: free hit counters using JavaScript ¤ SSI


CMP logo
CMP_home
home
Canadian Mind Products CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[24.87.56.253]
Your IP:[80.134.30.163]
You are visitor number 14486.
Please send errors, omissions and suggestions
to improve this page to Roedy Green.
You can get a fresh copy of this page from: or possibly from your local J: drive mirror:
http://mindprod.com/jgloss/hitcounter.html J:\mindprod\jgloss\hitcounter.html