aspose file tools*
The moose likes Servlets and the fly likes counter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "counter" Watch "counter" New topic
Author

counter

harivarma mudunuru
Greenhorn

Joined: Sep 07, 2000
Posts: 8
How can I know how many visitors are currently visiting my site using sevlets?
Sid Sharama
Greenhorn

Joined: Feb 06, 2005
Posts: 11
hi,
have an integer (say counter = 0) declared in your Servlet class.
in doGet() or doPost() increment the counter.
and while sending the response
out.println("so far" + count + "visits were made to this site");
sri
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Hmm. That will tell you how many have visited so far, but not how many are 'visiting' now. The latter is actually very difficult to figure out.
Say someone requests a page from your site. Do you assume they are actually reading it? A server can't tell if someone types in another URL to their browser to get a page frmo another site. A browser can't tell if a user walks away from the computer, or does something else completely. Is that what you are trying to find out?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: counter