You are absolutely right. I made it sound simple with certain presumptions.
Session tracking should be there to keep track of the user. Otherwise every
time the user revisits the servlet, it increments the count. Also the field
holding the count should be made persistent to ensure that the info (no of
visitors ) is not lost when the servlet is destroyed.
-----Original Message-----
From: Don Junio Edillor [SMTP:[EMAIL PROTECTED]]
Sent: Thursday, March 30, 2000 1:10 PM
To: [EMAIL PROTECTED]
Subject: Re: NEED HELP!!!
sorry, but i think you'll encounter problems with that.. everytime
the
doGet()/doPost() method was invoked, it will increment. but what if
that
servlet is often called due to same functionality.. or the user keep
on
going to the same page.. i mean the user goes back to main page..
therefore
with the same user, you could get numerous visits.. i think it would
be
ideal to use session.. once the user visited to the site or page,
you should
increment the no. of visitors saved from a file or database.. then
whenever
the user logged out, remove the session... if the user visited
again, it
will be counted again.. if the site doesnt support logging out, the
session
is active as long as the browser is running.. if you think ites not
pratical, i would suggest you use what Mr Ramarao had said.. but u
dont
actually get the no. of users who really visited the site, but the
no of
times the servlet was called.
>From: Ramarao Yadlapalli <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's
Java
> Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: NEED HELP!!!
>Date: Thu, 30 Mar 2000 09:07:27 +0530
>
>This is simple. Have a static int variable declared in the servlet
class
>scope, and increment that by one in the service()/doGet()/doPost()
>(whichever you may be using) method. For each user/visitor, a new
>service()/doGet()/doPost) is initiated and so you will have your
static
>variable indicating the number of times the service method was
invoked.
>This
>is same as the number of visitors.
>
> -----Original Message-----
> From: john swee [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, March 30, 2000 8:05 AM
> To: [EMAIL PROTECTED]
> Subject: NEED HELP!!!
>
> Hi!
> Who can send me a Servlet programm for counting
> visistors.
>
> Thank you very much!
>
> __________________________________________________
> Do You Yahoo!?
> Talk to your friends online with Yahoo! Messenger.
> http://im.yahoo.com
>
>
>___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and
include in
>the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives:
>http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
>http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in
the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives:
http://archives.java.sun.com/archives/servlet-interest.html
>Resources:
http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in
the body
of the message "signoff SERVLET-INTEREST".
Archives:
http://archives.java.sun.com/archives/servlet-interest.html
Resources:
http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html