Hi,
wrote:
> There's is a servlet that is having a service() and a doPost() in it
> and this servlet is extented by a class that also has a doPost()
> implemented.
>
> What actually happens is that :
>
> When request reaches my servlet then in the service() then I call
> doPost() method but instead of calling the doPost of the servlet its
> calling the doPost() of the child.
>
> Can anyone explain why is this happening?
It's not a bug, it's a feature! That is exactly what is supposed to
happen, it's not weird at all. That's what's OO about.
If you do not want that the method of the "subclass" (not "child") is
called, then you must not "override" it. To avoid (in the "superclass")
that the method can be "override" in a "subclass", you can declare the
method as "final". (Of course, in your case that leads to a compiler
error in the subclass. You have to rename the method in the subclass.)
I strongly suggest to read some OO-Books!
Ciao,
Ingo