File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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: 39549
    
  27
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 - updated with new look and Ping home screen widget
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: 39549
    
  27
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
 
Similar Threads
Basic Doubts in Header
addHeader & setHeader doubt
Response Header value in non US-ASCII character set
Doubt regarding Headers
Important ques: setHeader.addHeader