jQuery in Action, 2nd edition*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes service method 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 "service method" Watch "service method" New topic
Author

service method

Araad Izadkhah
Greenhorn

Joined: Nov 07, 2005
Posts: 15
hi,
this question was actually in the Whizlab (demo!) exam:
there was a form with the method "get" and an action.
in the processing servlet it only had the implementation of doPost(...,...) however it had an overridden service(req,res) in which you could find:
public void service(ServletRequest req,ServletResponse res)
{
doPost(req,res);
}

I answered to this question that "there won't be any output" because my understanding was that if you DO override the service method the first thing you do is to call super(req,res) otherwise it won't work.

which one us is right?
thx
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
What are the other choices?


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Araad Izadkhah
Greenhorn

Joined: Nov 07, 2005
Posts: 15
sorry i meant they said that the doPost will be executed.
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
Yes POST will be executed.
Araad Izadkhah
Greenhorn

Joined: Nov 07, 2005
Posts: 15
so no need for super() stuff?
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

I think, they are correct.

Whent executing the request come from client, the container executes first the service(ServletRequest, ServletResponse) method. This method calls the service(HttpServletRequest, HttpServletResponse) method. Here it is decided which doXXX method should executed. As you overiding the first service method, the call to the doPost()is a simple method call like any other method. the doPost method is not selected by container, but called explicitly by you like normanl method.

Hope it helps you

Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
 
wood burning stoves
 
subject: service method