Salman Roy
Salman Roy

Reputation: 575

How to get All tomcat HTTP Response

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.

Upvotes: 0

Views: 2732

Answers (2)

Emil L
Emil L

Reputation: 21081

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

Upvotes: 1

Manjula
Manjula

Reputation: 5091

Use a servlet (response) Filter 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

Upvotes: 4

Related Questions