This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
The doHead method in HttpServlet is a specialized form of the doGet method that returns only the headers produced by the doGet method.
Because we are sending the same req and res to every method,we can get every information in every method.
Only because you have overridden service. I guess you could say that in it's current state, your servlet may not be complying with the specification.
In order to comply: - don't override service. If you've extended HttpServlet, it will determine when a HEAD HTTP request has been received and will call doHead(). Triggering one of those may be tricky though!
Hope that clears things up a little.
MG [ June 19, 2007: Message edited by: Mark Garland ]
The doHead method default implementation returns a header by delegating processing to the doGet method and then ignoring the body. ... ... HEAD method is defined to return the headers for ther GET method, and no others. If the doGet method is not overridden, the doHead method should return the appopriate status code: either 400 for HTTP/1.0 or 405 for HTTP/1.1. ... ...