• 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

addHeader and getHeaders

 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to know how a new value is added to a header of a response.

For example:



Is it added after coma like:

//case1:
Content-Encoding: gzip, deflate

or

//case2:
Content-Encoding: gzip
Content-Encoding: deflate

Is getHeaders() [from HttpServletRequest] used to get values from case 1 or case 2?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anybody help?
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I read somewhere that for HTTP headers, that support multiple values, the values are added as comma separated values. And for headers that don't support multiple values, multiple headers are added i.e. case 2. Still I'll have to verify it by making a sample program and monitoring the headers...
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, thanks for an effort!
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Request.getHeaders(String) returns an Enumeration. So I think it should return the values as individual strings. However I have one basic doubt. Suppose I define a custom header say 'demoHeader' and set it in response like this:

response.addHeader('demoHeader', 'demoValue')

Now from where can I read this header value? The header will remain till the response has been sent to the browser. The subsequent request will not contain this header. This scenario might not have any significance in real life but I'm just curious...
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cannot get a header from response. You and the container set them so you should know them
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic