- Java EE Tutorials
- Servlets Tutorials
- Servlets Interview Questions
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:
| Name | Description | Type |
|---|---|---|
| Servlet | Defines methods that a servlet class must implement | Interface |
| ServletConfig | During initialization it allows the servlet container to pass information to a servlet. | Interface |
| ServletContext | Servlet Context is used to communicate with the servlet container to get the details of web application. | Interface |
| ServletContextListener | Receive notification about the changes made to the servlet context of the Web application. | Interface |
| ServletRequest | It is used to request client information to the servlet | Interface |
| ServletResponse | It is used by servlet to write the response content to the client. | Interface |
| SingleThreadModel | It uses the servlet instance to process only one request at a time. | Interface |
| ServletRequestListener | In the web component it receives a notification of the particular request that is coming in or out | Interface |
| ServletRequestAttributeListener | Notifies the changes in request attribute | Interface |
| ServletContextAttributeListener | The servlet context receives notification of the changes to be made on attribute list. | Interface |
| Filter | It is a reusable code that can transform the content of request, responses and the header information from one format to another. | Interface |
| FilterChain | Stores information about a chain of filters. | Interface |
| FilterConfig | It is used during the initialization. | Interface |
| RequestDispatcher | It is used to dispatch the request from one component to another. | Interface |
| ServletContextEvent | It gives the details of the life cycle events of the ServletContext object. | Class |
| ServletRequestEvent | Indicates that the request that is about to come in or go out of the web component. | Class |
| ServletRequestWrapper | Provides implementation of the ServletRequest interface to receive the request from a servlet. | Class |
| ServletResponseWrapper | Provides implementation of the ServletResponse interface to send response to the servlet. | Class |
| ServletRequestAttributeEvent | Servlet container invokes this method to indicate whether the attribute is to be added into the request, removed or replaced from the request. | Class |
| ServletContextAttributeEvent | Servlet container invokes this method to indicate whether the attribute is to be added into the context, removed or replaced from the context. | Class |
| ServletInputStream | Provides an input stream for reading a client requests. | Class |
| ServletOutputStream | Provides an output stream for writing servlet response to client. | Class |
| GenericServlet | Implements javax.servlet.Servlet interface and provides the basic implementation for the methods in this interface. | Class |
| ServletException | It is used to indicate that the request has generate an error. | Class |
| UnavailableException | Indicates 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:
| Name | Description | Type |
|---|---|---|
| HttpServletRequest | The web container provides implementation to this interface and encapsulates all HTTP based request information. | Interface |
| HttpServletResponse | Provide HTTP- specific functionality while sending a response. | Interface |
| HttpSession | It is a mechanism for storing client data across multiple HTTP requests. | Interface |
| HttpSessionBindingListener | Notifies when the objects of its implementation class is added or removed from the session. | Interface |
| Cookie | It is a file containing the information that is sent by web server to a client. | Class |
| HttpSessionBindingEvent | This method is used to indicate whether the object is added into the HttpSession object or removed from the HttpSession object. | Class |
| HttpServlet | Provides convenient methods for implementing for handling HTTP request. | Class |
Previous Tutorial : Introduction to Servlet || Next Tutorial : Servlet LifeCycle