This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes request headers question ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "request headers question ..." Watch "request headers question ..." New topic
Author

request headers question ...

Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585
Hi,

Can anybody help me in this

This is one of the questions in the HFSJ final mock,



Which "a" will be set ? The second one or there will be only one header named "a" with the value of "c" ?

Thanks in advance ...


Vassili ...
SCJP 5.0, SCWCD 1.4, SCJA 1.0
Mark Garland
Ranch Hand

Joined: Nov 11, 2006
Posts: 226
addHeader adds the header to the existing value
setHeader replaces it.

So header 'a' will have the value of 'c' at the end of these lines.


28/06/06 - SCJP - 69%, 05/06/07 - SCWCD - 92%, 28/02/08 - IBM DB2 v9 Fundamentals (Exam 730) - 87%, 18/11/08 - IBM DB2 v9 DBA (Exam 731) - 89%, 26/02/11 - SCBCD - 88%
Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585
OK, I got it now

Thanks ...
Tanveer Ahmad
Ranch Hand

Joined: Sep 20, 2005
Posts: 33
addHeader & setHeader work like this... If "a" DOES NOT exist then "a" is set (NOTE here I have used SET... simple...). If "a" DOES exist then addHeader ADDS (menas add the existing value) but the setHeader SETS (means overwrite existing value).
So the answer will be "c", since last statement is setHeader("a", "c");
Had it been like addHeader("a", "c"); then outcome would be "abc".

Hope this helps.
Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585
Hi,

It became even more clear, thanks Tanveer ...

Best of luck ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request headers question ...
 
Similar Threads
How to solve refresh problem in JSP
file name issue
page caching
response.addHeader() method
addHeader VS setHeader