Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Response Headers

 
Jiji Cherian
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
this is regarding adding headers in the response.

See the code snippet below...


Here i am adding two headers in the response with the same key.
is this possible? will there be two headers?

and what if i set the header as follows after adding two headers



which value get overridden?

Thanks and regards,
Jiji
 
Martyn Clark
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
to answer your question
response.addHeader("h1","v1");
response.addHeader("h1","v2");


The second time you are adding header you just add another value to "h1"
as in it will be h1: val1, val2

and then when you setHeader you over wright the values of h1 that you have added before your left with h1: val3

with add you are adding another value to that header and with set if there is already a header there you are replacing that value.
Hope that is of some help.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jiji,

Martyn says it all, but I'd like to point out that there is a naming policy at the forum. Please read and change your name according to it
http://www.javaranch.com/name.jsp

Thank you.
 
Jiji Cherian
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Martyn,
That helped.

Satou i have changed my display name.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic