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

doubt from hanumant book

 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following methods would you use to retrieve header values from a
request? (Select two)
a getHeader() of ServletRequest
b getHeaderValue() of ServletRequest
c getHeader() of HttpServletRequest
d getHeaders() of ServletRequest
e getHeaders() of HttpServletRequest
Answers: b and e
Explanation
Headers are a feature of the HTTP protocol. Thus, all the header-specific methods
belong to HttpServletRequest. getHeader() returns a String (or null),
while getHeaders() returns an Enumeration of all the values for that header
(or an empty Enumeration).


the exlanation seens right but isnt the answer c and e
 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The easiest way to find out is to check the documentation of ServletRequest/HttpServletRequest and see if there is a method named getHeaderValue in it...
 
Ali Murtaza Shaikh
Ranch Hand
Posts: 55
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ ted : yes you are right the answer is c and e because ServletRequest class does not have any methods related to headers in it... all the header related methods are in the HttpServletRequest class , and they are :

getHeader()
getHeaders()
getHeaderNames()
getInitHeader()
getDateHeader()

for further info you can check the API, or download this :
http://faq.javaranch.com/content/Ashok_SCWCD_API.doc
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic