Servlet API

The Servlet API is supported by all Servlet containers, such as Tomcat and Weblogic, etc. The Application Programming Interface (API) contains interface and classes to write a servlet program. The servlet API contains two packages as listed below:

  • javax.servlet
  • javax.servlet.http

Package javax.servlet

javax.servlet contains a number of classes and interface that allows the servlet to access the basic services provided by the servlet container. Following table lists the classes and interface of javax.servlet package:

NameDescriptionType
ServletDefines methods that a servlet class must implementInterface
ServletConfigDuring initialization it allows the servlet container to pass information to a servlet.Interface
ServletContextServlet Context is used to communicate with the servlet container to get the details of web application.Interface
ServletContextListenerReceive notification about the changes made to the servlet context of the Web application.Interface
ServletRequestIt is used to request client information to the servletInterface
ServletResponseIt is used by servlet to write the response content to the client.Interface
SingleThreadModelIt uses the servlet instance to process only one request at a time.Interface
ServletRequestListenerIn the web component it receives a notification of the particular request that is coming in or outInterface
ServletRequestAttributeListenerNotifies the changes in request attributeInterface
ServletContextAttributeListenerThe servlet context receives notification of the changes to be made on attribute list.Interface
FilterIt is a reusable code that can transform the content of request, responses and the header information from one format to another.Interface
FilterChainStores information about a chain of filters.Interface
FilterConfigIt is used during the initialization.Interface
RequestDispatcherIt is used to dispatch the request from one component to another.Interface
ServletContextEventIt gives the details of the life cycle events of the ServletContext object.Class
ServletRequestEventIndicates that the request that is about to come in or go out of the web component.Class
ServletRequestWrapperProvides implementation of the ServletRequest interface to receive the request from a servlet.Class
ServletResponseWrapperProvides implementation of the ServletResponse interface to send response to the servlet.Class
ServletRequestAttributeEventServlet container invokes this method to indicate whether the attribute is to be added into the request, removed or replaced from the request.Class
ServletContextAttributeEventServlet container invokes this method to indicate whether the attribute is to be added into the context, removed or replaced from the context.Class
ServletInputStreamProvides an input stream for reading a client requests.Class
ServletOutputStreamProvides an output stream for writing servlet response to client.Class
GenericServletImplements javax.servlet.Servlet interface and provides the basic implementation for the methods in this interface.Class
ServletExceptionIt is used to indicate that the request has generate an error.Class
UnavailableExceptionIndicates that the servlet is currently unavailable to the process.Class

Package javax.servlet.http

The servlets using HTTP protocol are supported by the package javax.servlet.http. The list of classes and interface of javax.servlet.http package are listed in the following table:

NameDescriptionType
HttpServletRequestThe web container provides implementation to this interface and encapsulates all HTTP based request information.Interface
HttpServletResponseProvide HTTP- specific functionality while sending a response.Interface
HttpSessionIt is a mechanism for storing client data across multiple HTTP requests.Interface
HttpSessionBindingListenerNotifies when the objects of its implementation class is added or removed from the session.Interface
CookieIt is a file containing the information that is sent by web server to a client.Class
HttpSessionBindingEventThis method is used to indicate whether the object is added into the HttpSession object or removed from the HttpSession object.Class
HttpServletProvides convenient methods for implementing for handling HTTP request.Class

Previous Tutorial : Introduction to Servlet  || Next Tutorial : Servlet LifeCycle

Comments

comments

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Speak Your Mind

*

Close
Please support the site
By clicking any of these buttons you help our site to get better