• 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,setHeader

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
I am not able to create a simple new header in my response (
can we do this in a getPost()?



But I am getting null for 's' .How should I add a new header?

Moreover I also tried to setHeader("CONTENT-LENGTH","1024");
and then tried to display the value for this header,but it did not show me the updated value.Why did not my setHeader method work? Why dint it replace the existing value?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The request and response objects obtained within the doGet/doPost methods are unrelated to one another. Any header set in the response will be available to the client to which it is sent - for web apps that is generally a browser. (In Firefox, you can see all headers using the "Tools -> Get Info" menu.)
 
amarkirt saroay
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This did not clarify my query? why am I not able to add this header?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You ARE able to add/set headers. But the response object has no methods for getting the headers that have been set, and the request object (which you're trying to use) has no relationship to the response object. So there's no way for you to check which headers haven been set in a response within the servlet container. The way to access response headers is to do it in the client to which the response is sent, like I mentioned about Firefox.
reply
    Bookmark Topic Watch Topic
  • New Topic