Overview of On-Line Version
We hope you enjoy this PDF version of the first edition of the international bestseller
Core Servlets and JavaServer Pages (courtesy of Sun Microsystems Press). If you are
interested in the second edition of the book, it is available through most major on-line
and brick-and-mortar bookstores. See http://www.coreservlets.com for details.
Interested in the sequel? Check out More Servlets and JavaServer Pages at
http://www.moreservlets.com.
Looking for servlet and JSP short courses
taught by the author? Visit
http://courses.coreservlets.com.
Available on-site at your company
or at public venues.
Chapter
© Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
Table of Contents
Second edition of this book: http://www.coreservlets.com.
Acknowledgments xix
About the Author
xx
Introduction xxi
Real Code for Real Programmers
xxii
How This Book Is Organized
xxiii
Conventions
xxvii
About the Web Site
xxvii
Part 1
Servlets 2.1 and 2.2
2
Chapter 1
Overview of Servlets and JavaServer Pages
4
1.1 Servlets
5
1.2 The Advantages of Servlets Over “Traditional” CGI
7
Efficient
7
Convenient
7
v
Sequel: http://www.moreservlets.com.
Servlet and JSP training courses: http://courses.coreservlets.com.
vi
Contents
© Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
Powerful
8
Portable
8
Secure
8
Inexpensive
9
1.3 JavaServer Pages
9
1.4 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
1.5 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 Java Compiler
14
Package the Classes
15
Configure the Server
16
Start the Server
17
Compile and Install Your Servlets
18
Chapter 2
First Servlets
20
2.1 Basic Servlet Structure
21
2.2 A Simple Servlet Generating Plain Text
23
Compiling and Installing the Servle