Servlet Packages

tutorial and example
tutorial and example

There are two packages in Java Servlet that provide various features to servlet. These two packages are javax.servlet and javax.servlet.http.

javax.servlet package: This package contains various servlet interfaces and classes which are capable of handling any type of protocol.

javax.servlet.http package: This  package contains various interfaces and classes which are capable of handling a specific http type of protocol.

Overview of some important interfaces and classes

javax.servlet package interface

Some of the important interfaces are listed below.

           Interface

                                                                                                    Overview

Servlet

This interface is used to create a servlet class. Each servlet class must require to implement this interface either directly or indirectly.

ServletRequest

The object of this interface is used to retrieve the information from the user.

ServletResponse

The object of this interface is used to provide response to the user.

ServletConfig

ServletConfig object is used to provide the information to the servlet class explicitly.

ServletContext

The object of ServletContext is used to provide the information to the web application explicitly.

javax.servlet package classes

Some of the important classes are listed below.

            Classes

                       Overview    

GenericServlet

This is used to create servlet class. Internally, it implements the Servlet interface.

ServletInputStream

This class is used to read the binary data from user requests.

ServletOutputStream

This class is used to send binary data to the user side.

ServletException

This class is used to handle the exceptions occur in servlets.

ServletContextEvent

If any changes are made in servlet context of web application, this class notifies.

javax.servlet.http package interface

Some of the important interface of this package are listed below:

          Interface

                        Overview

HttpServletRequest

The object of this interface is used to get the information from the user under http protocol.

HttpServletResponse

The object of this interface is used to provide the response of the request under http protocol.

HttpSession

This interface is used to track the information of users.

HttpSessionAttributeListener

This interface notifies if any change occurs in HttpSession attribute.

HttpSessionListener

This interface notifies if any changes occur in HttpSession lifecycle.

javax.servlet.http package classes

Some of the important interface of this package are listed below.

             Class

                   Overview

HttpServlet

This class is used to create servlet class.

Cookie

This class is used to maintain the session of the state.

HttpSessionEvent

This class notifies if any changes occur in the session of web application.

HttpSessionBindingEvent

This class notifies when any attribute is bound, unbound or replaced in a session.