File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes doHead() method calls?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "doHead() method calls??" Watch "doHead() method calls??" New topic
Author

doHead() method calls??

Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
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


Thanks <br />Poonam Agarwal SCWCD 86%
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9304
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9304
    
  17

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

Joined: May 02, 2006
Posts: 86
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.


Regards,<br />Sourin.
Suresh Babu Venkat
Ranch Hand

Joined: Sep 15, 2009
Posts: 30
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?


SCJP 6.0 (88%) | SCWCD 5.0 (89%)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doHead() method calls??