Tuesday, 29 October 2013

Different ways of creating a Servlet

Create Servlet

Hello, friends here we will learn about how to create servlet.
  1. Every servlet class is either directly or indirectly implemented from Servlet interface given by servlet API.
  2. For programmer convenience, servlet API as provided the same abstract base classes for creating servlet.
  3. While developing web applications, a programmer can create a servlet class, by using any one of the following three approaches.
  • By directly implementing our class from the servlet interface.
Public class myserv implements Servlet
{
}
  • By extending our servlet class from a base class called GenericServlet.
Public class myserv extends GenericServlet
{
}
  • By extending our servlet class from a base class called HttpServlet.
Public class myserv extends HttpServlet
{
}

No comments:

Post a Comment