Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

counter

 
harivarma mudunuru
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I know how many visitors are currently visiting my site using sevlets?
 
Sid Sharama
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic