This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Response object does not have getHeader

 
Napu Sun
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks mock exam in HFSJ.
All of sudden, I found Response object has no getHeader method (but with setHeader and addHeader).
But If I want to access the headers set in Response object, how can I do?
 
NDP Prasad
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Response object dont need the getHeader. why think a bit?
we have setHeader and addHeader in response because once if we forward the response to other jsp or servlets you can use it .
 
Napu Sun
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks NDP.
 
Rancy Chadha
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prasad,
we have setHeader and addHeader in response because once if we forward the response to other jsp or servlets you can use it .

I dont quite agree with you on this.
The reason I don't agree with you is that, whether you forward or include the response to other jsp or servlets, you are ultimately forwarding the original request and response objects that you have received from the client. Therefore even if you add or set headers on your response object it won't be available to the forwarded servlet.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!