I assume you've seen this post on implementing httplib?
http://www.ethereal.com/lists/ethereal-users/200512/msg00203.html

In the meanwhile Curl implements this feature with curl_setopt
http://us2.php.net/curl

M--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- From: "Huseyin Sinecan" <[EMAIL PROTECTED]>
To: <users@tomcat.apache.org>
Sent: Tuesday, April 24, 2007 9:29 AM
Subject: http header setting problem in servlet


                    Hello all,

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

I set parameters as below:

**************************************
theResponse.reset();
theResponse.resetBuffer();

theResponse.setHeader("Request Version", "HTTP/1.1");
 theResponse.setStatus(200);
 theResponse.setHeader("Date", "Wed, 18 Apr 2007 09:24:04 GMT");
 theResponse.setHeader("Server", "Tomcat");
 theResponse.addCookie(theRequest.getCookies()[0]);
 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");
 theResponse.setContentType("text/plain");

theResponse.flushBuffer();

//..........
//some other things...
//..........

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

aPrintWriter.flush();
**************************************

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
\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.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to