Servlet API
To create Java Servlets, we need to use Servlet API which contains all the necessary interfaces and classes. Servlet API has 2 packages namely
- javax.servlet
- javax.servlet.http
javax.servlet
This package support Generic servlet which is protocol independent. These interfaces and classes describe and define the contracts between a servlet class and the runtime environment provided by a servlet container.
Classes available in javax.servlet package
Classes |
Description |
GenericServlet |
Defines a generic, protocol-independent servlet. |
ServletInputStream |
Provides an input stream for reading binary data from a client request, including an efficient readLine method for reading data one line at a time. |
ServletOutputStream |
Provides an output stream for sending binary data to the client. |
ServletContextEvent |
This is the event class for notifications about changes to the servlet context of a web application. |
ServletContextAttributeEvent |
This is the event class for notifications about changes to the attributes of the servlet context of a web application. |
ServletRequestEvent |
Events of this kind indicate lifecycle events for a ServletRequest. |
ServletRequestAttributeEvent |
This is the event class for notifications of changes to the attributes of the servlet request in an application. |
Interface available in javax.servlet package
Interface |
Description |
Servlet |
Defines methods that all servlets must implement. |
ServletConfig |
A servlet configuration object used by a servlet container to pass information to a servlet during initialization. |
ServletContext |
Defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file. |
ServletRequest |
Defines an object to provide client request information to a servlet. |
ServletResponse |
Defines an object to assist a servlet in sending a response to the client. |
RequestDispatcher |
Defines an object that receives requests from the client and sends them to any resource (such as a servlet, HTML file, or JSP file) on the server. |
javax.servlet.http
This package describe and define the contracts between a servlet class running under the HTTP protocol and the runtime environment provided for an instance of such a class by a conforming servlet container.
Classes available in javax.servlet package
Classes |
Description |
Cookie |
Creates a cookie, a small amount of information sent by a servlet to a Web browser, saved by the browser, and later sent back to the server. |
HttpServlet |
Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. |
HttpServletRequestWrapper |
Provides a convenient implementation of the HttpServletRequest interface that can be subclassed by developers wishing to adapt the request to a Servlet. |
HttpServletResponseWrapper |
Provides a convenient implementation of the HttpServletResponse interface that can be subclassed by developers wishing to adapt the response from a Servlet. |
HttpSessionBindingEvent |
Events of this type are either sent to an object that implements HttpSessionBindingListener when it is bound or unbound from a session, or to a HttpSessionAttributeListener that has been configured in the deployment descriptor when any attribute is bound, unbound or replaced in a session. |
HttpSessionEvent |
This is the class representing event notifications for changes to sessions within a web application. |
Interface available in javax.servlet package
Interface |
Description |
HttpServletRequest |
Extends the ServletRequest interface to provide request information for HTTP servlets. |
HttpServletResponse |
Extends the ServletResponse interface to provide HTTP-specific functionality in sending a response. |
HttpSession |
Provides a way to identify a user across more than one page request or visit to a Web site and to store information about that user. |
HttpSessionActivationListener |
Objects that are bound to a session may listen to container events notifying them that sessions will be passivated and that session will be activated. |
HttpSessionAttributeListener |
This listener interface can be implemented in order to get notifications of changes to the attribute lists of sessions within this web application. |
HttpSessionBindingListener |
Causes an object to be notified when it is bound to or unbound from a session. |
HttpSessionListener |
Implementations of this interface are notified of changes to the list of active sessions in a web application. |
Next Topic :Servlet Example