• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

About doGet() adn doHead()  RSS feed

 
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!