Is java violating OOPS concept?
According to OOPS concept the subclass will get all the properties of base class...
But in case of servlets, HttpServlet is the subclass of GenericServlet and Generic servlet can be used for all protocols where as HttpServlet is used only for Http. In this case is java violating OOPS concept? What r ur suggetions friends?
> According to OOPS concept the subclass will get all
> the properties of base class...
> But in case of servlets, HttpServlet is the subclass
> of GenericServlet and Generic servlet can be used for
> all protocols where as HttpServlet is used only for
> Http. In this case is java violating OOPS concept?
> What r ur suggetions friends?
Generic servlet can't be used for any protocol. It's abstract. Where do you find a specification of GenericServlet in the docs that is not covered by HttpServlet as well?
Actually i read in a tutorial about the difference between GenericServlet and HttpServlet.In that it was like GenericServlet can be used for any protocols where as HttpServlet can use for Http. Can u plz explain what all are the differences between both?
> Actually i read in a tutorial about the difference
> between GenericServlet and HttpServlet.
> In that it was like GenericServlet can be used for
> any protocols where as HttpServlet can use for Http.
GenericServlet can't be used for anything. It's abstract. Believe me, I read it in the API docs.
> Can u plz explain what all are the differences
> between both?
HttpServlet is a http-specific implementation of GenericServlet. Everything an instance referred to by a reference of type GenericServlet can do can also be done by HttpServlet.
Another doubt is that HttpServlet is an abstract class but dont have even a single abstract method inside that. Then why it is an abstract class?
> Another doubt is that HttpServlet is an abstract
> class but dont have even a single abstract method
> inside that. Then why it is an abstract class?
Because either it's a pure design decision, or it doesn't implement certain abstract methods it inherits and is forcibly abstract. Maybe both.
So ur saying like if we can override some specific methods of GenericServlet in HttpServlet, then we can use HttpServlet for any protocols rt?
> So ur saying like if we can override some specific
> methods of GenericServlet in HttpServlet, then we can
> use HttpServlet for any protocols rt?
From the API docs:
Defines a generic, protocol-independent servlet.
Protocol-independent. Not "all protocols", but "no protocol".
that was a good reply... thanks dude....:)