Servlet API

Posted By on April 29, 2016


Download PDF
Servlet API and Overview
Servlet life cycle

A servlet is a Java programming language class that is used to extend the capabilities of servers that host applications access via a request-response programming model. The javax.servlet and javax.servlet.http packages provide interfaces and classes for writing servlets. The javax.servlet package contains many interfaces and classes that are used by the servlet or web container. These are not specific to any protocol. The javax.servlet.http package contains interfaces and classes that are responsible for http requests only.

All servlets must implement the Servlet interface which defines life-cycle methods. When implementing a generic service, you can use or extend the GenericServlet class provided with the Java Servlet API. The HttpServlet class provides methods, such as doGet and doPost, for handling HTTP-specific services.

Interfaces in javax.servlet package
There are many interfaces in javax.servlet package. They are as follows:

  • Servlet
  • ServletRequest
  • ServletResponse
  • RequestDispatcher
  • ServletConfig
  • ServletContext
  • SingleThreadModel
  • Filter
  • FilterConfig
  • FilterChain
  • ServletRequestListener
  • ServletRequestAttributeListener
  • ServletContextListener
  • ServletContextAttributeListener

Classes in javax.servlet package

There are many classes in javax.servlet package. They are as follows:

  • GenericServlet
  • ServletInputStream
  • ServletOutputStream
  • ServletRequestWrapper
  • ServletResponseWrapper
  • ServletRequestEvent
  • ServletContextEvent
  • ServletRequestAttributeEvent
  • ServletContextAttributeEvent
  • ServletException
  • UnavailableException

Interfaces in javax.servlet.http package

There are many interfaces in javax.servlet.http package. They are as follows:

  • HttpServletRequest
  • HttpServletResponse
  • HttpSession
  • HttpSessionListener
  • HttpSessionAttributeListener
  • HttpSessionBindingListener
  • HttpSessionActivationListener
  • HttpSessionContext (deprecated now)

Classes in javax.servlet.http package

There are many classes in javax.servlet.http package. They are as follows:

  • HttpServlet
  • Cookie
  • HttpServletRequestWrapper
  • HttpServletResponseWrapper
  • HttpSessionEvent
  • HttpSessionBindingEvent
  • HttpUtils (deprecated now)
Servlet API and Overview
Servlet life cycle

Download PDF