tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Huseyin Sinecan <>
Subject http header setting problem in servlet
Date Tue, 24 Apr 2007 13:29:41 GMT
                     Hello all,

I want to set header parameters of http response in my servlet.

I set parameters as below:


theResponse.setHeader("Request Version", "HTTP/1.1");
  theResponse.setHeader("Date", "Wed, 18 Apr 2007 09:24:04 GMT");
  theResponse.setHeader("Server", "Tomcat");
  theResponse.setHeader("pragma", "no-cache"); // HTTP 1.0
  theResponse.setHeader("Cache-Control", "no-cache"); // HTTP 1.1
  theResponse.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); // a past date
  theResponse.setDateHeader("Last-Modified", (new java.util.Date()).getTime());
  theResponse.setHeader("Connection", "close");


//some other things...

  PrintWriter aPrintWriter = theResponse.getWriter();
  aPrintWriter.write("this is the string to be put into the body part of the http packet.");


However, when I check what I am sending as response (using the ethereal network sniffing tool)
I see the result below:
HTTP/1.1 200 OK\r\n
     Request Version: HTTP/1.1
     Response Code: 200
Server: Apache-Coyote/1.1\r\n
Content-Length: 68\r\n
Date: Tue, 24 Apr 2007 17:55:10 GMT\r\n
Data (68 bytes)

I am setting header parameters as it should be.. But it doesn't care about my parameters and
Tomcat puts some values that it selects itself..

Would anyone has any idea about what I am doing wrong here..?

Thanks & Regards

Huseyin Sinecan

Ahhh...imagining that irresistible "new car" smell?
 Check outnew cars at Yahoo! Autos.
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message