aspose file tools*
The moose likes Servlets and the fly likes how to disable tomcat to set 'Etag' and 'last-modified'in the http resonse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to disable tomcat to set Watch "how to disable tomcat to set New topic
Author

how to disable tomcat to set 'Etag' and 'last-modified'in the http resonse

ying lam
Ranch Hand

Joined: May 17, 2004
Posts: 85
hi,
I use Tomcat to server a static image (i put the image in the 'images' under WEB-INF directory).

But when I do a HTTP trace, it always send back 'Etag' , 'Last-Modified' in http response.

HTTP/1.x 200 OK
Etag: W/"942-1165631787000"
Last-Modified: Sat, 09 Dec 2006 02:36:27 GMT
Content-Type: image/png
Content-Length: 942
Date: Mon, 11 Dec 2006 07:11:40 GMT
Server: Apache-Coyote/1.1


Can you please tell me how to disable that?

Thank you very much for any help.
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by ying lam:
I use Tomcat to server a static image (i put the image in the 'images' under WEB-INF directory).


If you are trying for a Trace command on a servet , then this would have been a easy task ,you could just override the doTrace method and construct the response yourself.
As you are trying to achieve on a image ,then I guess the Trace response is generated by the Cytoe connector.In that case you have to make your own connector and plug it into Tomcat Or, extend the Cyote connector and override the method that is generating the Trace response.


Rahul Bhattacharjee
LinkedIn - Blog
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61656
    
  67

Why?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ying lam
Ranch Hand

Joined: May 17, 2004
Posts: 85
Sorry ,I am not sure what you mean by trace command.

What I meant was :
In this http response:

HTTP/1.x 200 OK
Etag: W/"942-1165631787000"
Last-Modified: Sat, 09 Dec 2006 02:36:27 GMT
Content-Type: image/png
Content-Length: 942
Date: Mon, 11 Dec 2006 16:48:52 GMT
Server: Apache-Coyote/1.1

i want tomcat not to add 'Etag' and 'Last-Modified'.

Thak yo.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Are you sure that Tomcat is adding the ETag?
I just checked my copy and don't see them.

The Last-Modified header is part of the HTTP/1.1 spec.
I doubt you will find an easy way to disable that without writing something yourself.
I don't think it would be difficult to write a servlet filter that does this.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

To re-iterate Bear's question...
Why?
D Rog
Ranch Hand

Joined: Feb 07, 2004
Posts: 472

You can use servlet to control returned headers. You can neglect performance overhead in case of Java web server anyway.


Retire your iPod and start with HD Android music player Kamerton | Minimal J2EE container is here | Light weight full J2EE stack | and build tool | Co-author of "Windows programming in Turbo Pascal"
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to disable tomcat to set 'Etag' and 'last-modified'in the http resonse