wood burning stoves 2.0*
The moose likes Servlets and the fly likes counts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "counts" Watch "counts" New topic
Author

counts

Umesha Asaigoli
Greenhorn

Joined: Nov 11, 2000
Posts: 6
I need to maintain a count for hits on couple of pages. Not for the display the number of visitors in the website. Rather, it is for tracking sensitive information access(maintained in web pages) times in the applications. User will not be having any login to the system and hence no session tracking. I am expecting this would be pretty simple but I donno it. Please help me out. Any help is appreciated.
Umesha Asaigoli
Greenhorn

Joined: Nov 11, 2000
Posts: 6
Please help me JSP techniques to handle hit counts of the page w/o the user login. The nature of the counter pretty much same as visitors counter in the webpages. In my case I don't need to display in the page at all. Counts would stored in the server and may it can be re-initialized once server is down. Please help me out if any one did that in their project.
Kapil Agrawal
Greenhorn

Joined: Nov 03, 2000
Posts: 11
You might want to initialize a static variable in a java class constructor and load this class at the time of server startup. Then your jsp page can just increment the variable as a regular feature, without having to worry about the counter value. You can use the same java class to store the counter variable in DB or where-ever required.
Hope it helps.
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
Here's one way to do it using jsp. This method should maintain the count as long as the server has not been shutdown/restarted.
First make a javabean, something along the lines of:

Next, your jsp would look something like:

If you need to maintain your hit count even after server restart, simply add code to save off the count, and add the code to retrieve the count in the constructor.
Hope this is helpful.
J
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: counts