wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes dohead Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "dohead" Watch "dohead" New topic
Author

dohead

Amruth Puppala
Ranch Hand

Joined: Jul 14, 2008
Posts: 295
as per java API
GET request also automatically supports an HTTP HEAD
request


1.even if we don't override doHead method can we make head request.
2. If we override doHead method and make head request wich method will be called doHead or doGet


SCJP 5 |SCWCD 5| Started thinking about Web Services ?
Sunny Jain
Ranch Hand

Joined: Jul 23, 2007
Posts: 433

Actually GET = HEAD + message Body

If you override the doHead method and call the doHead method, then by simple java rules, it must call doHead( ) method.


Thanks and Regards,
SCJP 1.5 (90%), SCWCD 1.5 (85%), The Jovial Java, java.util.concurrent tutorial
Amruth Puppala
Ranch Hand

Joined: Jul 14, 2008
Posts: 295
Thanks Sunny,
So waht about

1.even if we don't override doHead method can we make head request.
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

Yes, because this method is implemented in the HttpServlet class (doHead)

Therefore if your servlet extends HttpServlet class (which is an abstract class) the HEAD request will be handled by the doHead() which is defined in the superclass (HttpServlet).

Regards,
Krzysiek


SCJP 5.0, SCWCD 5.0, SCBCD 5.0, SCEA/OCMJEA 5.0
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

I've checked the HttpServlet implementation and it looks like the doHead() method doesn't do anything useful by default:

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41151
    
  45
That looks very useful to me; in fact, it's exactly what it should be doing, which is to execute a GET but to return an empty response body.


Ping & DNS - my free Android networking tools app
Jan Sterk
Ranch Hand

Joined: Jun 06, 2008
Posts: 139
Slightly off-topic: so are the defalut implementations of doGet and doPost the only methods that throw a NotSupportedException? Or doPut and doDelete also?

Where can you check the source code of HttpServlet?


SCJP 1.4 (81%)<br />SCWCD 5 (95%)
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

Just search for "HttpServlet source" You may find it here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dohead
 
Similar Threads
doHead question?
query about doHead() method
doHead processing
SCWCD Hints #19
Doubt in doHead() method