HttpServlet class is an abstract class defined in "javax.servlet.http" package and is sub class of GenericServlet class defined in "javax.servlet" package. GenericServlet class is used to define a generic, protocol-independent servlet but HttpServlet class provides an HTTP protocol specific implementation. If your servlet has to work with HTTP protocol then your servlet needs to extend HttpServlet class. This class provides various doXXX() methods which can be overridden according to the type of request. This class also provides service() methods that can also be overridden but we don't need to do so because it calls the appropriate doXXX() method according to the method of request. Generally, doGet() or doPost() methods are needed to be overridden to handle the GET or POST requests.
Posted on: November 11, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles