wood burning stoves 2.0*
The moose likes Servlets and the fly likes Calculating number of hits that my web-application has received. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Calculating number of hits that my web-application has received." Watch "Calculating number of hits that my web-application has received." New topic
Author

Calculating number of hits that my web-application has received.

Chaitanya Devavarapu
Greenhorn

Joined: Dec 06, 2006
Posts: 19
Hi friends,

I have a requirement to calculate the number of hits that my
web-application has received. How to solve this requirement?

Thanks in advance.
Chaitanya
Chaitanya Devavarapu
Greenhorn

Joined: Dec 06, 2006
Posts: 19
Hi friends,

Please suggest a better way by using Servlets/JSP

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

What constitutes a "hit"?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Sounds like the job of a synchronized singleton that encapsulates a static variable, all drawbacks to synchronization aside.

Remember, having all Servlets update a single variable creates a single bottleneck in your application.

-Cameron McKenzie
Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
hi,

You can use simple variable to fetch count from database & again increment this count if hit ocurs for certain page & persist/update this into database.

In second method you can use variable with application scope to hold count of the visits to certain page in your application. But drawback of this method is that it will hold count only untill your server is alive/running. Once you restart your server the "application" variable gets reset. So you need to implement some method to persist this variable in regular inerval of time into database.

Cheers,
Pras


********Deserve Before You Desire********
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calculating number of hits that my web-application has received.
 
Similar Threads
How to get the number of hits per page in java
More complicated Program
How to run a program on application startup in tomcat?
Auto Generation of Sequence Numbers
Number of hits per web page