The Java™ EE 5 Tutorial

icon

1224

pages

icon

English

icon

Documents

Écrit par

Publié par

Le téléchargement nécessite un accès à la bibliothèque YouScribe Tout savoir sur nos offres

icon

1224

pages

icon

English

icon

Ebook

Le téléchargement nécessite un accès à la bibliothèque YouScribe Tout savoir sur nos offres

The Java™ EE 5
Tutorial
For Sun Java System Application Server Platform Edition 9
Jennifer Ball
Debbie Bode Carson
Ian Evans
Kim Haase
Eric Jendrock
February 18, 2006 Copyright © 2004 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 License.
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 ...
Voir Alternate Text

Publié par

Nombre de lectures

127

Langue

English

Poids de l'ouvrage

8 Mo

The Java™ EE 5 Tutorial For Sun Java System Application Server Platform Edition 9 Jennifer Ball Debbie Bode Carson Ian Evans Kim Haase Eric Jendrock February 18, 2006 Copyright © 2004 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 License. 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 © 2004 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 permis. 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. . . . . . . . . . . . . . . . . . . . . . . . . . xxv Who Should Use This Tutorial xxv Prerequisites xxv About the Examples xxvi Further Information xxix How to Print This Tutorial xxix Typographical Conventions xxx Feedback xxx Chapter 1: Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Distributed Multitiered Applications 2 Java EE Components 3Clients 4 Web Components 6 Business Components 6 Enterprise Information System Tier 7 Java EE Containers 8 Container Services 8 Container Types 9 Web Services Support 10 XML 11 SOAP Transport Protocol 12 WSDL Standard Format 12 UDDI and ebXML Standard Formats 13 Packaging Applications 13 Development Roles 15 Java EE Product Provider 15 Tool Provider 15 Application Component Provider 16 iii iv CONTENTS Application Assembler 16 Application Deployer and Administrator 17 Java EE 5 APIs 18 Enterprise JavaBeans Technology 18 Java Servlet Technology 19 JavaServer Pages Technology 19 JavaServer Pages Standard Tag Library 19 JavaServer Faces 20 Java Message Service API 20 Java Transaction API 20 JavaMail API 21 JavaBeans Activation Framework 21 Java API for XML Processing 21 Java API for XML-Based RPC 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 23 JDBC API 24 Java Naming and Directory Interface 24 Java Authentication and Authorization Service 25 Simplified Systems Integration 25 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 Derby Database Server 29 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 Web Modules 43 Testing Deployed Web Modules 46 Listing Deployed Web Modules 46 Updating Web Modules 47 Undeploying Web Modules 49 CONTENTS v Configuring Web Applications 50 Mapping URLs to Web Components 50 Declaring Welcome Files 51 Setting Initialization Parameters 52 Mapping Errors to Error Screens 52 Declaring Resource References 53 Duke’s Bookstore Examples 56 Accessing Databases from Web Applications 57 Populating the Example Database 57 Creating a Data Source in the Application Server 58 Further Information 58 Chapter 3: Java Servlet Technology . . . . . . . . . . . . . . . . . . . . . 59 What Is a Servlet? 59 The Example Servlets 60 Troubleshooting 62 Servlet Life Cycle 63 Handling Servlet Life-Cycle Events 63 Handling Errors 66 Sharing Information 66 Using Scope Objects 66 Controlling Concurrent Access to Shared Resources 68 Accessing Databases 69 Initializing a Servlet 70 Writing Service Methods 71 Getting Information from Requests 72 Constructing Responses 74 Filtering Requests and Responses 77 Programming Filters 77 Programming Customized Requests and Responses 79 Specifying Filter Mappings 82 Invoking Other Web Resources 84 Including Other Resources in the Response 84 Transferring Control to Another Web Component 86 Accessing the Web Context 87 Maintaining Client State 88 Accessing a Session 88 Associating Objects with a Session 88 Session Management 89 Session Tracking 90 vi CONTENTS Finalizing a Servlet 91 Tracking Service Requests 91 Notifying Methods to Shut Down 92 Creating Polite Long-Running Methods 93 Further Information 94 Chapter 4: JavaServer Pages Technology . . . . . . . . . . . . . . . .95 What Is a JSP Page? 95 Example 96 The Example JSP Pages 99 The Life Cycle of a JSP Page 104 Translation and Compilation 104 Execution 105 Creating Static Content 107 Response and Page Encoding 107 Creating Dynamic Content 108 Using Objects within JSP Pages 108 Unified Expression Language 109 Immediate and Deferred Evaluation Syntax 111 Value and Method Expressions 113 Defining a Tag Attribute Type 118 Deactivating Expression Evaluation 119 Literal Expressions 121 Resolving Expressions 122 Implicit Objects 125 Operators 126 Reserved Words 127 Examples 127 Functions 129 JavaBeans Components 130 JavaBeans Component Design Conventions 131 Creating and Using a JavaBeans Component 132 Setting JavaBeans Component Properties 133 Retrieviponent Properties 136 Using Custom Tags 136 Declaring Tag Libraries 137 Including the Tag Library Implementation 139 Reusing Content in JSP Pages 139 Transferring Control to Another Web Component 140 jsp:param Element 141 CONTENTS vii Including an Applet 141 Setting Properties for Groups of JSP Pages 144 Further Information 147 Chapter 5: JavaServer Pages Documents . . . . . . . . . . . . . . . 149 The Example JSP Document 150 Creating a JSP Document 152 Declaring Tag Libraries 154 Including Directives in a JSP Document 156 Creating Static and Dynamic Content 158 Using the jsp:root Element 161 Using the jsp:output Element 162 Identifying the JSP Document to the Container 166 Chapter 6: JavaServer Pages Standard Tag Library . . . . . . . 167 The Example JSP Pages 168 Using JSTL 169 Tag Collaboration 170 Core Tag Library 172 Variable Support Tags 172 Flow Control Tags 174 URL Tags 177 Miscellaneous Tags 178 XML Tag Library 180 Core Tags 181 Flow Control Tags 182 Transformation Tags 183 Internationalization Tag Library 184 Setting the Locale 185 Messaging Tags 185 Formatting Tags 186 SQL Tag Library 187 query Tag Result Interface 189 Functions 191 Further Information
Voir Alternate Text
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents
Alternate Text