Servlets, Filters, and Listeners
A servlet is a
Java class that
extends a server with functionality for processing a request and
producing a response. It’s implemented using the
classes and interfaces defined by the
Servlet API. The API consists of two
packages: the javax.servlet
package contains
classes and interfaces that are protocol-independent, while the
javax.servlet.http
package provides HTTP-specific
extensions and utility classes.
What makes a servlet a servlet is that the class implements an
interface named
javax.servlet.Servlet
,
either directly or by extending one of the support classes. This
interface defines the methods used by the web container to manage and
interact with the servlet. A servlet for processing HTTP requests
typically extends the
javax.servlet.http.HttpServlet
class. This class implements the
Servlet
interface and provides additional methods
suitable for HTTP processing.
Get JavaServer Pages, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.