File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

service method

 
Araad Izadkhah
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1026
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the other choices?
 
Araad Izadkhah
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry i meant they said that the doPost will be executed.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes POST will be executed.
 
Araad Izadkhah
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so no need for super() stuff?
 
Narendra Dhande
Ranch Hand
Posts: 951
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic