Forums Register Login

doHead() method calls??

+Pie Number of slices to send: Send
Which of the following statements is correct?

1. GenericServlet defines but does not implement doHead() method.
2. The default implementation of HttpServlet class's doHead() method calls the doGet() method.
3. The HttpServlet class does not implement a dummy doHead() method.
4. There is no special method for HEAD request, doGet() handles HEAD requests.
5. If the servlet does not implement doHead(), doGet() will be called upon HTTP HEAD request.

The above question is from Enthuware mock and the mentioned right option is 2.

Can anybody elaborate it more OR suggest something to verify for the same.

Thanks
+Pie Number of slices to send: Send
well the doHead method of HttpServlet class calls the doGet method and returns only the headers of the response to the client. To test this I think you'll have to make a custom doHead request to a servlet using java.net.Socket or java.net.URL class. If there is any other easier way then I don't know about it...
+Pie Number of slices to send: Send
This is from the documentation of doGet method of HttpServlet class

Overriding this method to support a GET request also automatically supports an HTTP HEAD request. A HEAD request is a GET request that returns no body in the response, only the request header fields.

 
+Pie Number of slices to send: Send
 

Ankit Garg wrote:To test this I think you'll have to make a custom doHead request to a servlet using java.net.Socket or java.net.URL class. If there is any other easier way then I don't know about it...


There surely isnt any easier method to do this. Either use these classes or some other library, but in either case, you will end up creating connections and making calls manually via code.
+Pie Number of slices to send: Send
 

Poonam Agarwal wrote:Which of the following statements is correct?

1. GenericServlet defines but does not implement doHead() method.
2. The default implementation of HttpServlet class's doHead() method calls the doGet() method.
3. The HttpServlet class does not implement a dummy doHead() method.
4. There is no special method for HEAD request, doGet() handles HEAD requests.
5. If the servlet does not implement doHead(), doGet() will be called upon HTTP HEAD request.

The above question is from Enthuware mock and the mentioned right option is 2.

Can anybody elaborate it more OR suggest something to verify for the same.

Thanks




i am just wondering if 2 is correct, option 5 also should be correct ,but why only 2 is given as answer

or if we dont override any doXXX method and call that method,its throws a exception?

Hug your destiny! And hug this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1484 times.
Similar Threads
dohead
HEAD
doHead
Question on HTTP methods
doHead processing
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 09:45:45.