background image

Java Servlet Technology

<< Creating a Data Source in the Application | The Example Servlets >>
<< Creating a Data Source in the Application | The Example Servlets >>

Java Servlet Technology

Java Servlet Technology
As soon as the web began to be used for delivering services, service providers recognized the
need for dynamic content. Applets, one of the earliest attempts toward this goal, focused on
using the client platform to deliver dynamic user experiences. At the same time, developers also
investigated using the server platform for this purpose. Initially, Common Gateway Interface
(CGI) scripts were the main technology used to generate dynamic content. Although widely
used, CGI scripting technology has a number of shortcomings, including platform dependence
and lack of scalability. To address these limitations, Java Servlet technology was created as a
portable way to provide dynamic, user-oriented content.
What Is a Servlet?
A servlet is a Java programming language class that is used to extend the capabilities of servers
that host applications accessed by means of a request-response programming model. Although
servlets can respond to any type of request, they are commonly used to extend the applications
hosted by web servers. For such applications, Java Servlet technology defines HTTP-specific
servlet classes.
The
javax.servlet
and
javax.servlet.http
packages provide interfaces and classes for writing
servlets. All servlets must implement the
Servlet
interface, which defines life-cycle methods.
When implementing a generic service, you can use or extend the
GenericServlet
class provided
with the Java Servlet API. The
HttpServlet
class provides methods, such as doGet and doPost,
for handling HTTP-specific services.
This chapter focuses on writing servlets that generate responses to HTTP requests.
4
C H A P T E R
4
99