• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doHead() method calls??

 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sourin K. Sen
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Suresh Babu Venkat
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic