文档介绍:© Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
Chapter
Table of Contents
Acknowledgments xix
About the Author xx
Introduction xxi
Real Code for Real Programmers xxii
How This Book anized xxiii
Conventions xxvii
About the Web Site xxvii
Part 1
Servlets and 2
Chapter 1
Overview of Servlets and JavaServer Pages 4
Servlets 5
The Advantages of Servlets Over “Traditional” CGI 7
Efficient 7
Convenient 7
Home page for this book: .
Home page for sequel: .
Servlet and JSP training courses: http://courses..
v
© Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
vi Contents
Powerful 8
Portable 8
Secure 8
Inexpensive 9
JavaServer Pages 9
The Advantages of JSP 10
Versus Active Server Pages (ASP) 10
Versus PHP 10
Versus Pure Servlets 11
Versus Server-Side Includes (SSI) 11
Versus JavaScript 11
Versus Static HTML 12
Installation and Setup 12
Obtain Servlet and JSP Software 12
Bookmark or Install the Servlet and JSP API Documentation 14
Identify the Classes to the piler 14
Package the Classes 15
Configure the Server 16
Start the Server 17
Compile and Install Your Servlets 18
Chapter 2
First Servlets 20
Basic Servlet Structure 21
A Simple Servlet Generating Plain Text 23
Compiling and Installing the Servlet 24
Invoking the Servlet 25
A Servlet That Generates HTML 26
Packaging Servlets 27
Creating Servlets in Packages 28
Compiling Servlets in Packages 29
Invoking Servlets in Packages 30
Simple HTML-Building Utilities 31
The Servlet Life Cycle 34
The init Method 34
The service Method 36
© Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
Contents vii
The doGet, doPost, and doXxx Methods 37
The SingleThreadModel Interface 38
The destroy Method 38
An Example Using Initialization Parameters 39
An Example Using Servlet Init