Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Chaitanya Devavarapu
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

Please suggest a better way by using Servlets/JSP

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What constitutes a "hit"?
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic