Académique Documents
Professionnel Documents
Culture Documents
Hans Bergsten
Publisher: O'Reilly
August 2002
ISBN: 0-596-00317-X, 684 pages
Filled with useful examples and the depth, clarity, and attention to detail that made the first
edition so popular with web developers, JavaServer Pages, 2nd Edition is completely revised
and updated to cover the substantial changes in the 1.2 version of the JSP specifications, and
includes coverage of the new JSTL Tag libraries-an eagerly anticipated standard set of JSP
elements for the tasks needed in most JSP applications, as well as thorough coverage of
Custom Tag Libraries.
Copyright 2002, 2001 O'Reilly & Associates, Inc. All rights reserved.
Printed in the United States of America.
Published by O'Reilly & Associates, Inc., 1005 Gravenstein Highway North, Sebastopol,
CA 95472.
O'Reilly & Associates books may be purchased for educational, business, or sales
promotional use. Online editions are also available for most titles (http://safari.oreilly.com).
For more information contact our corporate/institutional sales department: 800-998-9938 or
corporate@oreilly.com.
Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered
trademarks of O'Reilly & Associates, Inc. Java and all Java-based trademarks and logos are
trademarks or registered trademarks of Sun Microsystems, Inc., in the United States and other
countries. O'Reilly &x Associates, Inc., is independent of Sun Microsystems. Openwave,
the Openwave logo, and UP.SDK are trademarks of Openwave Systems Inc. All rights
reserved.
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in this book, and O'Reilly
& Associates, Inc. was aware of a trademark claim, the designations have been printed in caps
or initial caps. The association between the image of a grey wolf and the topic of JavaServer
Pages is a trademark of O'Reilly & Associates, Inc.
While every precaution has been taken in the preparation of this book, the publisher and
the author assume no responsibility for errors or omissions, or for damages resulting from the
use of the information contained herein.
Table of Contents
Table of Contents
Preface ................................................................................................................................... 1
What's in the Book ............................................................................................................. 2
Readers of the First Edition................................................................................................ 2
Audience............................................................................................................................. 3
Organization ....................................................................................................................... 4
About the Examples ........................................................................................................... 8
Conventions Used in This Book......................................................................................... 8
How to Contact Us ............................................................................................................. 9
Acknowledgments for First Edition ................................................................................... 9
Acknowledgments for Second Edition............................................................................. 10
Part I: JSP Application Basics .............................................................................................. 12
Chapter 1. Introducing JavaServer Pages ....................................................................... 13
1.1 What Is JavaServer Pages?......................................................................................... 13
1.2 Why Use JSP? ............................................................................................................ 14
1.2.1 Embedding Dynamic Elements in HTML Pages ................................................ 14
1.2.2 Compilation......................................................................................................... 15
1.2.3 Using the Right Person for Each Task ................................................................ 15
1.2.4 Integration with Enterprise Java APIs................................................................. 16
1.2.5 Other Solutions.................................................................................................... 16
1.2.6 The JSP Advantage ............................................................................................. 18
1.3 What You Need to Get Started................................................................................... 18
Chapter 2. HTTP and Servlet Basics................................................................................ 20
2.1 The HTTP Request/Response Model......................................................................... 20
2.1.1 Requests in Detail................................................................................................ 21
2.1.2 Responses in Detail ............................................................................................. 23
2.1.3 Request Parameters ............................................................................................. 25
2.1.4 Request Methods ................................................................................................. 25
2.2 Servlets ....................................................................................................................... 27
2.2.1 Advantages over Other Server-Side Technologies ............................................. 27
2.2.2 Servlet Containers ............................................................................................... 29
2.2.3 Servlet Contexts and Web Applications.............................................................. 30
Chapter 3. JSP Overview................................................................................................... 32
3.1 The Problem with Servlets ......................................................................................... 32
3.2 The Anatomy of a JSP Page....................................................................................... 34
3.3 JSP Processing............................................................................................................ 34
3.3.1 JSP Elements ....................................................................................................... 35
3.4 JSP Application Design with MVC ........................................................................... 37
Chapter 4. Setting Up the JSP Environment................................................................... 39
4.1 Installing the Java Software Development Kit........................................................... 39
4.2 Installing the Tomcat Server ...................................................................................... 40
4.2.1 Windows Platforms ............................................................................................. 41
4.2.2 Unix Platforms (Including Linux and Mac OS X) .............................................. 43
4.3 Testing Tomcat........................................................................................................... 43
4.4 Installing the Book Examples .................................................................................... 45
4.5 Example Web Application Overview ........................................................................ 47
Table of Contents
ii
Table of Contents
iii
Table of Contents
iv
Table of Contents
Table of Contents
vi
Table of Contents
vii