文档介绍:© Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
Overview of
Servlets and
Chapter
JavaServer Pages
Topics in This Chapter
• What servlets are
• When and why you would use servlets
• What JavaServer Pages are
• When and why you would use JSP
• Obtaining the servlet and JSP software
• Software installation and setup
Home page for this book: .
Home page for sequel: .
Servlet and JSP training courses: http://courses..
© Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
Chapter
his chapter gives a quick overview of servlets and JavaServer Pages
(JSP), outlining the major advantages of each. It then summarizes
T how to obtain and configure the software you need to write servlets
and develop JSP documents.
Servlets
Servlets are Java technology’s answer mon Gateway Interface (CGI)
programming. They are programs that run on a Web server, acting as a mid-
dle layer between a ing from a Web browser or other HTTP cli-
ent and databases or applications on the HTTP server. Their job is to:
1. Read any data sent by the user.
This data is usually entered in a form on a Web page, but could
e from a Java applet or a custom HTTP client program.
2. Look up any other information about the request that is
embedded in the HTTP request.
This information includes details about browser capabilities,
cookies, the host name of the requesting client, and so forth.
5
© Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
6 Chapter 1 Overview of Servlets and JavaServer Pages
3. Generate the results.
This process may require talking to a database, executing an
RMI or CORBA call, invoking a legacy application, put-
ing the response directly.
4. Format the results inside a document.
In most cases, this involves embedding the information inside
an HTML page.
5. Set the appropriate HTTP response parameters.
This means telling the bro