I am not able to create a simple new header in my response (
can we do this in a getPost()?
But I am getting null for 's' .How should I add a new header?
Moreover I also tried to setHeader("CONTENT-LENGTH","1024");
and then tried to display the value for this header,but it did not show me the updated value.Why did not my setHeader method work? Why dint it replace the existing value?
The request and response objects obtained within the doGet/doPost methods are unrelated to one another. Any header set in the response will be available to the client to which it is sent - for web apps that is generally a browser. (In Firefox, you can see all headers using the "Tools -> Get Info" menu.)
Joined: Mar 16, 2008
This did not clarify my query? why am I not able to add this header?
Joined: Mar 22, 2005
You ARE able to add/set headers. But the response object has no methods for getting the headers that have been set, and the request object (which you're trying to use) has no relationship to the response object. So there's no way for you to check which headers haven been set in a response within the servlet container. The way to access response headers is to do it in the client to which the response is sent, like I mentioned about Firefox.