-
Click Counter (3 messages)
- Posted by: A M
- Posted on: March 29 2007 00:52 EDT
Hi All, Presently we have a servlet counting the number of click on a page and storing the details in the DB. Currently we are persisting the information in DB on every click. No we want to change store the information in a bulk i.e. we need to temproraly persist the click details somewhere. We are planning to use a syncronized static collection object (along with its getter and setter methods) to store this. However we want to know if there is any better solution to this rather than using static variable as i guess we can have performance issues with static variables. cheers amitThreaded Messages (3)
- Re: Click Counter by James David on March 30 2007 00:27 EDT
- Re: Click Counter by Biswa Das on April 02 2007 12:07 EDT
- Re: Click Counter by John Smith on April 03 2007 01:48 EDT
-
Re: Click Counter[ Go to top ]
- Posted by: James David
- Posted on: March 30 2007 00:27 EDT
- in response to A M
may be you can consider using a message driven bean. So, on every click, post a message, and let the message driven bean call the persistence api to persist. And regarding when the actual persistence happens can be decided by the persistence layer i.e. it can buffer the data and do a bulk update or write them on each invocation etc. Thus, you need not prepare your own datastructure to maintain the clicks and periodically persist etc. And, you also achieve good performance (as far as the client is concerned) because the whole task is achieved asynchronously. Further, you have to fine tune the persistence with either bulk update or individual update etc, which is transparent. -
Re: Click Counter[ Go to top ]
- Posted by: Biswa Das
- Posted on: April 02 2007 12:07 EDT
- in response to James David
Add a one pixel transparent image to your web pages and intercept the requests to that image through a filter and do what ever you like in that filter. -
Re: Click Counter[ Go to top ]
- Posted by: John Smith
- Posted on: April 03 2007 01:48 EDT
- in response to A M
AMIT:We are planning to use a syncronized static collection object (along with its getter and setter methods) to store this.
Wont work if you are using multiple JVMs (common scenario in a production deployment)DAVID:may be you can consider using a message driven bean. So, on every click, post a message...
Too n/w (and probably cpu/memory) intensive.BISWA: Add a one pixel transparent image to your web pages..
Nice! My 2cents: Use a distributed cache (like ehcache) which is able to autoflush/persist to a db based on a required buffer/cache size.