I need to capture the incoming URL request in the Tomcat server. For example, i need a java program should run in the server, which always listen the incoming request in the server. whenever the user hits the request URL in the tomcat server i need to capture those request URL in my java program.Can you please suggest what is the best way to capture the request in the server(Tomcat). Do i need to write socket program to listen on server port ? or Do i need to create listener on apache tomcat server.xml to listen the incoming request ? Kindly help on this. Thanks in advance.
Asked
Active
Viewed 700 times
1
-
you need to write and setup a servelet to serve the requests – hhafeez Feb 21 '17 at 13:42
-
How about Filter concept to be introduced ? – sitakant Feb 21 '17 at 13:42
-
For example i have 3 applications deployed in one tomcat instance. I need to capture every request.if the user hits 3 application URL then i need to capture all the 3 requests. Is that possible to capture all the application request by using the one servlet ? So the servlet should be in separate application right ? – Roshan Feb 21 '17 at 13:46
-
you should update your question too with this new info. As sitakant mentioned, Filters will do the trick for you. You need to define a single filter in your web.xml for all of your applications – hhafeez Feb 21 '17 at 13:52
1 Answers
0
you can follow this guide to enable tomcat server write customized logs combined by user agent, browser and hit http://www.techstacks.com/howto/configure-access-logging-in-tomcat.html

Amr Zaky
- 21
- 5
-
These logs concept does not work for me. Because i need to capture the requested URL whenever the user tries to hit the URL. But if i writes the requested URL in log i won't know when the user requested the URL. So whenever the user requested the URL i need to capture the URL that time itself. – Roshan Feb 23 '17 at 13:47