Question: i want to trace all http response of tomcat when it recevice http request by code,
i have search a bit and i found org.apache.catalina and org.apache.coyote jar these jars have connector, response and Standard host classes, but i am unsuccessful to use these classes to achieve required result,

can any one help me in this regards how i use these classes is there any examplw aur tutorial by which i get tomcat http request's reponse in java and write them in file.

any help in this regards is greatly appreciated thanks.

Answer: 
Use a servlet (response) [Filter](http://docs.oracle.com/javaee/5/api/javax/servlet/Filter.html) and map it to /\* url pattern. 

From the java doc:

> 
> A filter is an object that performs filtering tasks on either the
>  request to a resource (a servlet or static content), or on the
>  **response from a resource**, or both.
> 
> 
> Filters perform filtering in the doFilter method. Every Filter has
>  access to a FilterConfig object from which it can obtain its
>  initialization parameters, a reference to the ServletContext which it
>  can use, for example, to load resources needed for filtering tasks.
> 
> 
> Filters are configured in the deployment descriptor of a web
>  application
> 
> 
> Examples that have been identified for this design are 
> 
> 
> 1. Authentication Filters
> 2. Logging and Auditing Filters
> 3. Image conversion Filters
> 4. Data compression Filters
> 5. Encryption Filters
> 6. Tokenizing Filters
> 7. Filters that trigger resource access events
> 8. XSL/T filters 9) Mime-type chain Filter
> 
> 
>
If you only need to log some properties of a request to file then I suggest looking at the built in logging capabilities of tomcat:

<http://tomcat.apache.org/tomcat-7.0-doc/config/valve.html>

Check out the access log valve and how to configure it to log different properties of a request. General info on tomcat configuration can be found here:

<http://tomcat.apache.org/tomcat-7.0-doc/config/index.html>