Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
ying lam
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why?
 
ying lam
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To re-iterate Bear's question...
Why?
 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use servlet to control returned headers. You can neglect performance overhead in case of Java web server anyway.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic