I am working on development of web application where i need to track the number of hits to a particular web application from client side using Ajax.
MyEar has below wars:
- APP-a
- APP-b (using Spring framework 3.1.0 )
- APP-c (using Spring framework 3.1.0 )
- APP-d
I want to track/count(using filters in APP-b and APP-c) the number of request to application APP-b and APP-c from a APP-d(using ajax)
I cannot use session as my APP-b and APP-c are stateless.
Thanks for any help 🙂
You can use interceptors.
1)If you want to have separate count of requests to APP-b and APP-c, just define a static variable in your both apps. Every time , a request is received in the interceptor, check whether it is from APP-d. If it is, increment the static counter. Keep on updating the file or db(where you are saving your count) periodically after some time.
2)If you want to have overall count as total no of hits in both your apps, then you should use a cache that supports clustering(most of caches do), so that you will be able to access it from both your apps. After receiving request, get previous count from cache , increment it and update it in your file or database.