Jump to content
xisto Community
kvarnerexpress

Jsp Pages Visited

Recommended Posts

Hi all,I want to keep track of how often certain pages are visited but I don't want to have it such that someone can keep refreshing a page to increment the number of times a page is visited.What would be the best way to keep track of visiters on my site so I can know what pages they are going to.I'm going to database this data so I can generate a little "most visited" list for my page of, say, the top 5 most visited pages.I imagine using a cookie or something but I would like to have a time frame on it, such that, if the same person re-visits the site after, x amount of time (an hour/day), the page 'hit' will increment.

Share this post


Link to post
Share on other sites

hi kvarnerexpress,yeah you can use session in this case.When someone visits the page, use the session id to identify which session is requesting the page and put it in a hashmap with the count. and/or time. Now when the page is requested again. check whether it is from the same session, if it is, then compare the time of last visit and update the count if sufficient time has elapsed else just serve the page.You need to run a cleanup routine at regular intervals so that the sessions in the hashmap that have not been used for a long time are removed so as to free up the space..Cheers.

Share this post


Link to post
Share on other sites

I started a class that should mesure hits, visits, etc per day (in a servlet) today...I will post the result soon!

Share this post


Link to post
Share on other sites

Use session variables. But good idea is save the session variable in a database. (such as IP address etc..). After that you can control you counter as much as you want.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.