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.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access