Win a copy of The Java Performance Companion this week in the Performance 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic