Win a copy of Spark in Action this week in the Open Source Projects 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

About doGet() adn doHead()

 
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
 
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
 
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.
 
Onion rings are vegetable donuts. Taste this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic