File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Important ques: setHeader.addHeader 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 "Important ques: setHeader.addHeader" Watch "Important ques: setHeader.addHeader" New topic

Important ques: setHeader.addHeader

amarkirt saroay
Ranch Hand

Joined: Mar 16, 2008
Posts: 167
if there exists already a header by name and value :
MyHeader: mydata
Now what will be the result of following code on it?

Ans is mydata3,mydata ...Please explain how?

Tom Kowalski
Ranch Hand

Joined: Feb 17, 2009
Posts: 72
First of all, you should write where have you found this question.


when you are using setHeader you are deleting the old contents of the header, and you are puting into it a new value.
when you are using addHeader you are NOT deleting old contents, you just add a new value to this header.

amarkirt saroay
Ranch Hand

Joined: Mar 16, 2008
Posts: 167
Thanks,i took this question from HFJS mock exam.
Nicky McGrath

Joined: Jun 24, 2004
Posts: 3
So the real question is:
If you have a Header with multiple values (as occurs after multiple calls to addHeader),
does setHeader replace ALL the existing values.

Good question.
Omer Haderi
Ranch Hand

Joined: Sep 27, 2006
Posts: 42
the spec is clear about setHeader "the values are cleared and replaced with the new value"

therefore all values will be cleared
I agree. Here's the link:
subject: Important ques: setHeader.addHeader
jQuery in Action, 3rd edition