Win a copy of Hello World this week in the Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

doubt from hanumant book

 
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
 
Sheriff
Posts: 9671
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • 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...
 
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
 
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!