Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

setHeader() and addHeader() methods

 
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a query regarding the setHeader() and addHeader() methods belonging to the HttpServletResponse class.

If the header is 'content-type' and already the header exists in the response, then setHeader() will replace the value of the existing content-type with the new value.

But how does the addHeader() method work for content-type? I think browser will be able to recognize only one content type at a time i.e. content-type header cannot have more than one value.

Please let me know how this works or correct me if I'm wrong in my understanding.

Many Thanks
Vijay
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Weclome to JavaRanch.

This is one of the things that you can easily test: whether the first header takes precendence, the second, both, none, or something else. What happened when you tried it?
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic