JavaEETutorial, work, e-books, j2ee
[ Pobierz całość w formacie PDF ]
The Java™ EE 5
Tutorial
For Sun Java System Application Server Platform Edition 9
Jennifer Ball
Debbie Carson
Ian Evans
Scott Fordin
Kim Haase
Eric Jendrock
June 16, 2006
Copyright © 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A.
All rights reserved.U.S. Government Rights - Commercial software. Government users are subject to the
Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supple-
ments.
This distribution may include materials developed by third parties.
Sun, Sun Microsystems, the Sun logo, Java, JavaBeans, JavaServer, JavaServer Pages, Enterprise Java-
Beans, Java Naming and Directory Interface, JavaMail, JDBC, EJB, JSP, J2EE, J2SE, “Write Once, Run
Anywhere”, and the Java Coffee Cup logo are trademarks or registered trademarks of Sun Microsystems,
Inc. in the U.S. and other countries.
Unless otherwise licensed, software code in all technical materials herein (including articles, FAQs, sam-
ples) is provided under this
.
Products covered by and information contained in this service manual are controlled by U.S. Export Con-
trol laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical
biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly pro-
hibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export
exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is
strictly prohibited.
DOCUMENTATION IS PROVIDED "AS IS" AND ALL EXPRESS OR IMPLIED CONDITIONS,
REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MER-
CHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE
DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE
LEGALLY INVALID.
Copyright © 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, États-
Unis. Tous droits réservés.
Droits du gouvernement américain, utlisateurs gouvernmentaux - logiciel commercial. Les utilisateurs
gouvernmentaux sont soumis au contrat de licence standard de Sun Microsystems, Inc., ainsi qu aux dis-
positions en vigueur de la FAR [ (Federal Acquisition Regulations) et des suppléments à celles-ci.
Cette distribution peut comprendre des composants développés pardes tierces parties.
Sun, Sun Microsystems, le logo Sun, Java, JavaBeans, JavaServer, JavaServer Pages, Enterprise Java-
Beans, Java Naming and Directory Interface, JavaMail, JDBC, EJB, JSP, J2EE, J2SE, “Write Once, Run
Anywhere”, et le logo Java Coffee Cup sont des marques de fabrique ou des marques déposées de Sun
Microsystems, Inc. aux États-Unis et dans d’autres pays.
A moins qu’autrement autorisé, le code de logiciel en tous les matériaux techniques dans le présent (arti-
cles y compris, FAQs, échantillons) est fourni sous ce
Les produits qui font l’objet de ce manuel d’entretien et les informations qu’il contient sont régis par la
législation américaine en matière de contrôle des exportations et peuvent être soumis au droit d’autres
pays dans le domaine des exportations et importations. Les utilisations finales, ou utilisateurs finaux, pour
des armes nucléaires, des missiles, des armes biologiques et chimiques ou du nucléaire maritime, directe-
ment ou indirectement, sont strictement interdites. Les exportations ou réexportations vers des pays sous
embargo des États-Unis, ou vers des entités figurant sur les listes d’exclusion d’exportation américaines,
y compris, mais de manière non exclusive, la liste de personnes qui font objet d’un ordre de ne pas partic-
iper, d’une façon directe ou indirecte, aux exportations des produits ou des services qui sont régi par la
législation américaine en matière de contrôle des exportations ("U .S. Commerce Department’s Table of
Denial Orders "et la liste de ressortissants spécifiquement désignés ("U.S. Treasury Department of Spe-
cially Designated Nationals and Blocked Persons "),, sont rigoureusement interdites.
LA DOCUMENTATION EST FOURNIE "EN L’ÉTAT" ET TOUTES AUTRES CONDITIONS, DEC-
LARATIONS ET GARANTIES EXPRESSES OU TACITES SONT FORMELLEMENT EXCLUES,
DANS LA MESURE AUTORISEE PAR LA LOI APPLICABLE, Y COMPRIS NOTAMMENT TOUTE
GARANTIE IMPLICITE RELATIVE A LA QUALITE MARCHANDE, A L’APTITUDE A UNE
UTILISATION PARTICULIERE OU A L’ABSENCE DE CONTREFAÇON.
Contents
About This Tutorial. . . . . . . . . . . . . . . . . . . . . . . . . xxvii
Who Should Use This Tutorial
xxvii
Prerequisites
xxvii
How to Read This Tutorial
xxviii
About the Examples
xxx
Further Information
xxxiv
How to Print This Tutorial
xxxiv
Typographical Conventions
xxxiv
Feedback
xxxv
Chapter 1: Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Java EE Application Model
2
Distributed Multitiered Applications
3
Security
4
Java EE Components
4
Java EE Clients
4
Web Components
7
Business Components
7
Enterprise Information System Tier
9
Java EE Containers
9
Container Services
9
Container Types
10
Web Services Support
11
XML
12
SOAP Transport Protocol
13
WSDL Standard Format
13
UDDI and ebXML Standard Formats
13
Java EE Application Assembly and Deployment
14
Packaging Applications
14
iii
iv
C
ONTENTS
Development Roles
16
Java EE Product Provider
16
Tool Provider
16
Application Component Provider
17
Application Assembler
17
Application Deployer and Administrator
18
Java EE 5 APIs
19
Enterprise JavaBeans Technology
19
Java Servlet Technology
20
JavaServer Pages Technology
20
JavaServer Pages Standard Tag Library
20
JavaServer Faces
20
Java Message Service API
21
Java Transaction API
21
JavaMail API
21
JavaBeans Activation Framework
22
Java API for XML Processing
22
Java API for XML Web Services (JAX-WS)
22
Java Architecture for XML Binding (JAXB)
23
SOAP with Attachments API for Java
23
Java API for XML Registries
23
J2EE Connector Architecture
24
Java Database Connectivity API
24
Java Persistence API
24
Java Naming and Directory Interface
25
Java Authentication and Authorization Service
26
Simplified Systems Integration
26
Sun Java System Application Server Platform Edition 9
26
Tools
27
Starting and Stopping the Application Server
28
Starting the Admin Console
29
Starting and Stopping the Java DB Database Server
30
Debugging Java EE Applications
30
Part One: The Web Tier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Chapter 2: Getting Started with Web Applications. . . . . . . . . . 35
Web Application Life Cycle
38
Web Modules
40
Packaging Web Modules
42
Deploying a WAR File
43
C
ONTENTS
v
Testing Deployed Web Modules
44
Listing Deployed Web Modules
44
Updating Web Modules
45
Undeploying Web Modules
47
Configuring Web Applications
48
Mapping URLs to Web Components
48
Declaring Welcome Files
49
Setting Initialization Parameters
50
Mapping Errors to Error Screens
50
Declaring Resource References
51
Duke’s Bookstore Examples
54
Accessing Databases from Web Applications
54
Populating the Example Database
55
Creating a Data Source in the Application Server
55
Further Information
56
Chapter 3: Java Servlet Technology . . . . . . . . . . . . . . . . . . . . . 57
What Is a Servlet?
57
The Example Servlets
58
Troubleshooting
60
Servlet Life Cycle
61
Handling Servlet Life-Cycle Events
61
Handling Errors
64
Sharing Information
64
Using Scope Objects
64
Controlling Concurrent Access to Shared Resources
65
Accessing Databases
67
Initializing a Servlet
68
Writing Service Methods
69
Getting Information from Requests
70
Constructing Responses
72
Filtering Requests and Responses
75
Programming Filters
75
Programming Customized Requests and Responses
77
Specifying Filter Mappings
80
Invoking Other Web Resources
82
Including Other Resources in the Response
82
Transferring Control to Another Web Component
84
Accessing the Web Context
85
Maintaining Client State
86
[ Pobierz całość w formacie PDF ]