• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Intercepting requests.

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am planning to write one web analytics servlet(that will intercept each requests to the tomcat server, log the request header detail into database). I dont have a clue how to route all requests to the tomcat to my analytics servlet. Should I use any filter? or any suggestion?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you only need it to intercept requests for one application, then a filter will work nicely. If you need to intercept requests for all applications running under an instance of Tomcat, a Valve might be easier.

Tomcat ships with a valve that does something similar to what you're doing.
Instead of writing to a database, however, it writes to a log file.
Look in tomcat/conf/server.xml for the RequestDumperValve entry.
It's commented out by default.

Since Tomcat is open source, you can download the code to the valve to see how they're intercepting requests. This might be a good way to get started.
 
Squanch that. And squanch this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic