File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setHeader() and addHeader() methods

 
Vijayanarayana Reddy Bhoomireddy
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic