Win a copy of AWS Security this week in the Cloud/Virtualization 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

doHead method

Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per Servlet 2.3 specifications, there is a doHead method to handle the Head request. However, the book Java Servlet Programming states that when a doHead method is requested, the service method modifies the response object to suppress the body content and forwards the reqest to doGet method. Any ideas on this one ?
Ranch Hand
Posts: 5390
Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in servlet2.2 there was no doHead() method. I think you are using old book.
In servlet2.3 there is doHead() method also.
========== from API ===========
protected void doHead(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
Receives an HTTP HEAD request from the protected service method and handles the request. The client sends a HEAD request when it wants to see only the headers of a response, such as Content-Type or Content-Length. The HTTP HEAD method counts the output bytes in the response to set the Content-Length header accurately.
If you override this method, you can avoid computing the response body and just set the response headers directly to improve performance. Make sure that the doHead method you write is both safe and idempotent (that is, protects itself from being called multiple times for one HTTP HEAD request).
If the HTTP HEAD request is incorrectly formatted, doHead returns an HTTP "Bad Request" message.
req - the request object that is passed to the servlet
resp - the response object that the servlet uses to return the headers to the clien
Throws: - if an input or output error occurs
ServletException - if the request for the HEAD could not be handled
[ June 19, 2002: Message edited by: Ravish Kumar ]
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic