aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes addHeader,setHeader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "addHeader,setHeader" Watch "addHeader,setHeader" New topic
Author

addHeader,setHeader

amarkirt saroay
Ranch Hand

Joined: Mar 16, 2008
Posts: 167
HI,
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?


SCJP-75%
SCWCD-82%
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42292
    
  64
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.)


Ping & DNS - my free Android networking tools app
amarkirt saroay
Ranch Hand

Joined: Mar 16, 2008
Posts: 167
This did not clarify my query? why am I not able to add this header?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42292
    
  64
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: addHeader,setHeader