Servlets are Java programs that run within a web server environment. More specifically, servlets are Java programs that conform to the servlet API. Two packages make up most of the functionalities of the servlet API, namely, javax.servlet
and javax.servlet.http
. The former encompasses the most general servlet APIs. The latter contains the API for handling HTTP requests. javax.servlet.http
has a number of classes and interfaces whose main goal is to implement HTTP functionality. One of the most important classes in the package javax.servlet.http
is the abstract class HttpServlet
. Servlets inherit their HTTP-related methods from this class. Custom-developed servlets override one or more methods defined in HttpServlet
. These methods receive an object as a parameter that contains data about the underlying request and an object that they use to write the response. We will go into details about these methods and their parameters later on in the chapter.