tags:

views:

252

answers:

1

what is the best way for creating a jsp visitor hit counters? is it better to use txt file and save the hit value into a file, or create a table in database??? or use session/cookie to count the users whom have visited the website?

+2  A: 

That are a lot of questions. I'll answer them separately.

what is the best way for creating a jsp visitor hit counters?

A Filter which listens on the url-pattern matching the requests of interest. Maybe *.jsp?

is it better to use txt file and save the hit value into a file, or create a table in database???

A database is definitely faster. If you don't have or can't afford one, then live with a text file. Be careful that you don't save it inside the webapplication, but externally elsewhere on the local disk file system. Else it will get lost whenever you redeploy the webapplication.

or use session/cookie to count the users whom have visited the website?

Only use this to count the amount of user-specific visits during the user-specific session. Do not use this to count the sitewide amount of visits or whenever you care the cookie value to be manipulated.

BalusC
thanks, do you have any useful link to help me for filter and URL-pattern matching.??? BTW, how can I improve my 0% rate? many thanks for ur answer
Accepting solutions by pressing the check mark will increase your rate.
Flash84x