File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Tracking Requests and Responses Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Tracking Requests and Responses" Watch "Tracking Requests and Responses" New topic

Tracking Requests and Responses

Janaki Raju

Joined: Apr 14, 2008
Posts: 8
I hope I am posting this question in the right forum.

I have a web application running on tomcat. I want to take a look at the HTTP requests and responses (both header and data). How do I do this ? Is there any add-ons that I can add to the browser that will enable me to do this ? Or is there a way that I can tell tomcat to dump the requests and responses ? I am interested in the data being sent and received, not just the headers.

Any help is appreciated.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

Would servlet filters fit the bill to do this programmatically?

Or, Firefox plugins such as TamperData and Live HTTP Headers might be helpful for hand inspections.
[ June 24, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
Janaki Raju

Joined: Apr 14, 2008
Posts: 8

Thanks so much for responding back. TamperData and LiveHTTPHeaders seem to display only the headers, not the data portion.

What I need is:

If I use PostMethod in my java program to post a request, I want to see this request that I am sending and also the response that I am getting back (both header and data). Is there any way to add a sniffer like tool and bind it to a port to do this job ?

I am unfamiliar with how servlet filters work . Do you think they will do the above job that I need ?

Thanks much.
Abhinav Srivastava
Ranch Hand

Joined: Nov 19, 2002
Posts: 354

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Uncomment the requestDumperValve in tomcat/conf/server.xml.
There is a comment just above it that describes what it will send to the logs.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: Tracking Requests and Responses
It's not a secret anymore!