This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About doGet() adn doHead()

 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,
If I have servlet class that have method doGet() and doHead(), which method from both will be called by container to allow its servlet to handle a HEAD request?
thanks
daniel
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the API for HttpServlet.
doGet() is called by the service() method to handle GET requests.
doHead() is called by the service() method to handle HEAD requests.
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have read the API of HttpServlet.
In doGet() method, It say that
"Overriding this method to support a GET request also automatically supports an HTTP HEAD request"
Back to my question before, If I have servlet class that have method doGet() and doHead(), which method from both will be called by container to allow its servlet to handle a HEAD request?
daniel
 
Mark Howard
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your doHead() will handle the HEAD requests, and the doGet() will service the GET requests.
doGet() will handle HEAD requests in the absence of an overridden doHead() method.
Well that's what I was told anyway
Try it out.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic