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

setHeader() doubt

 
Srividhya Kiran
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what will be the value of head?

response.addHeader("head", "foo");
response.addHeader("head", "baz");
response.setHeader("head", "bar");

when we call request.getHeader("head");

Srividhya
[ August 11, 2008: Message edited by: Srividhya Kiran ]
 
Paul Brabban
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I don't think that setting a header in the response affects headers in the request, so request.getHeader("head") could return null or a String object, can't be determined from the information given.

Cheers,

Paul
 
Chatura Dilan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Paul that's true,
What's the propose of adding our own custom headers to response, if we cannot get them back?
 
Amruth Puppala
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Originally posted by Chatu Dil:
Yes, Paul that's true,
What's the propose of adding our own custom headers to response, if we cannot get them back?


Why can't we get headers back.
We have HttpServletRequest.getHeaders(String name) method, with wich we can get the Enumeration of values for single header.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65337
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chintu sirivennela:
We have HttpServletRequest.getHeaders(String name) method, with wich we can get the Enumeration of values for single header.
That will return request headers not response headers.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65337
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chatu Dil:
What's the propose of adding our own custom headers to response, if we cannot get them back?
Response headers are intended for the client. So if your client is the browser, there's not much use to them. But if the client is an Ajax request, or some custom client, the custom headers can be read and processed by that client. Remember, there's more to HTTP than just the browsers.
 
Amruth Puppala
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear Bibeault ,

I'm extreamly sorry for my overlook.

Now I got the context.
 
deepa raj
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ans: bar
 
Chatura Dilan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Bear, no it returns null, because there is no header called 'head' in the request and they are response headers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic