File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes  getHeaders(s) or getHeaderValues(s)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark " getHeaders(s) or getHeaderValues(s)?" Watch " getHeaders(s) or getHeaderValues(s)?" New topic

getHeaders(s) or getHeaderValues(s)?

Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 672
my Servlet 2.3 API only lists request.getHeaders() but one of my book (Deshmukh SCWCD study) only lists request.getHeaderValues().
Is the book wrong?

We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design

Crazy Bikes created by m-Power
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
When in doubt, check the specs

SRV.4.3 Headers
A servlet can access the headers of an HTTP request through the following methods of the HttpServletRequest interface:
• getHeader
• getHeaders
• getHeaderNames
The getHeader method returns a header given the name of the header. There can be multiple headers with the same name, e.g. Cache-Control headers, in an HTTP request. If there are multiple headers with the same name, the getHeader method returns the first head in the request. The getHeaders method allows access to all the header values associated with a particular header name, returning an Enumeration of String objects.
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 672
It looks like my book is wrong.
Louise Haydu
Ranch Hand

Joined: Aug 17, 2000
Posts: 51
Errata has been published for the book at Also be sure to check out the author's online forum for errors that haven't yet been incorporated into the errata page.
I agree. Here's the link:
subject: getHeaders(s) or getHeaderValues(s)?
It's not a secret anymore!