aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Need solution for Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Need solution for Question" Watch "Need solution for Question" New topic
Author

Need solution for Question

ramya ray
Ranch Hand

Joined: Aug 11, 2006
Posts: 101
Consider the following code:
public class WWServlet extends HttpServlet
{
....
}
What methods do you need to implement so that it compiles without any errors?


Options

Select 1 correct option.

service()


doService()


doGet


all doXXX methods


No method as HttpServlet has dummy implementations.
Bachi Taurean
Greenhorn

Joined: Aug 03, 2006
Posts: 26
Question not clear


Success is never ending and Failure is neve Final
Sreeraj G Harilal
Ranch Hand

Joined: Apr 19, 2006
Posts: 310
For compilation, there is no need to implement any method.


public class WWServlet extends HttpServlet
{

}


it works fine


SCJP 5.0<br />SCWCD 1.4<br />Preparing for <b>SCEA</b>.<br /><b>"I prefer an interesting vice to a virtue that bores."</b>
Sayak Banerjee
Ranch Hand

Joined: Nov 28, 2006
Posts: 292
Yeah....you don't need to but you can implement the doXXX methods....the question has not been framed properly
[ December 03, 2006: Message edited by: Sayak Banerjee ]

Turn on, tune in, drop out.
Bryan Basham
author
Ranch Hand

Joined: Apr 30, 2001
Posts: 199
Hi all,

The question is "OK" and the answer is the last one: no methods need to be implemented to make the WWServlet class compile.

However, I would argue that this is not a very good question, because it does not measure any reasonable skill or knowledge. A better question would be to ask "Given this servlet class, what would happen if you issued a GET request on this servlet?" Without looking it up, can anyone quess the answer?

-Bryan
[ December 03, 2006: Message edited by: Bryan Basham ]
Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 547

Originally posted by Bryan Basham:
Hi all,

The question is "OK" and the answer is the last one: no methods need to be implemented to make the WWServlet class compile.

However, I would argue that this is not a very good question, because it does not measure any reasonable skill or knowledge. A better question would be to ask "Given this servlet class, what would happen if you issued a GET request on this servlet?" Without looking it up, can anyone quess the answer?

-Bryan

[ December 03, 2006: Message edited by: Bryan Basham ]



I think the container will display an error page complaining that there is no doGet(...) method defined.
But I have another question, the specs say :
"A subclass of HttpServlet must override at least one method, usually one of these:

* doGet, if the servlet supports HTTP GET requests
* doPost, for HTTP POST requests
* doPut, for HTTP PUT requests
* doDelete, for HTTP DELETE requests
* init and destroy, to manage resources that are held for the life of the servlet
* getServletInfo, which the servlet uses to provide information about itself "

I do not understand the "at least one method" part here.
Since a class that extends the class HttpServlet without implementing any method will compile.
Can you explain ?


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCBCD 5
Visit my blog
Bryan Basham
author
Ranch Hand

Joined: Apr 30, 2001
Posts: 199
Well done, Celinio, that is correct. Specifically, the default implementations of the doXyz methods in HttpServlet returns the 501 code (functionality not implemented) in the response.

And to answer your question about the servlet spec. IMHO, this line in the spec should be rewritten like this: "To be useful, a subclass of HttpServlet must override at least one method..." Yes, it is true that an empty servlet class definition will compile and can be installed in a web container, but what use will it serve? None!

HTH,
Bryan
 
Consider Paul's rocket mass heater.
 
subject: Need solution for Question