The J2EE Tutorial for the Sun ONE Platform
486 pages
English

The J2EE Tutorial for the Sun ONE Platform

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

Description

The J2EE™ Tutorial for the
Sun™ ONE Platform
Eric Armstrong
Stephanie Bodoff
Maydene Fisher
Dale Green
Kim Haase
February 13, 2003 Copyright © 2003 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, J2EE, JavaServer Pages, Enterprise JavaBeans, Java Naming
and Directory Interface, EJB, JSP, J2EE, J2SE 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, Fads, 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 ...

Sujets

Informations

Publié par
Nombre de lectures 110
Langue English
Poids de l'ouvrage 3 Mo

Extrait

The J2EE™ Tutorial for the Sun™ ONE Platform Eric Armstrong Stephanie Bodoff Maydene Fisher Dale Green Kim Haase February 13, 2003 Copyright © 2003 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, J2EE, JavaServer Pages, Enterprise JavaBeans, Java Naming and Directory Interface, EJB, JSP, J2EE, J2SE 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, Fads, 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 © 2003 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 Micro- systems, Inc., ainsi qu aux dispositions 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, JavaServer Pages, Enterprise JavaBeans, Java Naming and Directory Interface, EJB, JSP, J2EE, J2SE 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. . . . . . . . . . . . . . . . . . . . . . . . . . . vii Who Should Use This Tutorial vii Prerequisites viii How to Read This Tutorial viii About the Examples ix Further Information x How to Print This Tutorial xi Typographical Conventions xi Chapter 1: Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Web Services Support 3 Distributed Multitiered Applications 5 J2EE Containers 11 Packaging 13 Development Roles 14 J2EE APIs 17 Chapter 2: Introduction to Web Applications. . . . . . . . . . . . . . 25 Web Application Life Cycle 26 Web Modules 28 Configuring Web Modules 30 Deploying W 33 Listing Deployed Web Modules 34 Running Web Applications 34 Updating Web Modules 35 Undeploying W 36 Duke’s Bookstore 37 Internationalizing and Localizing Web Applications 38 Accessing Databases from Web Applications 39 iii iv CONTENTS Further Information 45 Chapter 3: Java Servlet Technology . . . . . . . . . . . . . . . . . . . . .47 What is a Servlet? 47 The Example Servlets 48 Servlet Life Cycle 51 Sharing Information 54 Initializing a Servlet 58 Writing Service Methods 59 Filtering Requests and Responses 64 Invoking Other Web Resources 72 Accessing the Web Context 75 Maintaining Client State 76 Finalizing a Servlet 79 Further Information 82 Chapter 4: JavaServer Pages Technology . . . . . . . . . . . . . . . .83 What Is a JSP Page? 83 The Example JSP Pages 86 The Life Cycle of a JSP Page 88 Initializing and Finalizing a JSP Page 91 Creating Static Content 92 Creating Dynamic Content 92 Including Content in a JSP Page 98 Transferring Control to Another Web Component 100 Including an Applet 100 JavaBeans Components in JSP Pages 103 Extending the JSP Language 111 Further Information 112 Chapter 5: Custom Tags in JSP Pages . . . . . . . . . . . . . . . . . . .113 What Is a Custom Tag? 114 The Example JSP Pages 114 Using Tags 118 Defining Tags 122 Examples 137 CONTENTS v Chapter 6: JavaServer Pages Standard Tag Library . . . . . . . 149 The Example JSP Pages 150 Using JSTL 151 Expression Language Support 153 Core Tags 159 XML Tags 165 Internationalization Tags 169 SQL Tags 172 Further Information 176 Chapter 7: Understanding XML . . . . . . . . . . . . . . . . . . . . . . . . 177 Introduction to XML 177 XML and Related Specs: Digesting the Alphabet Soup 187 Generating XML Data 199 Designing an XML Data Structure 233 Chapter 8: Introduction to Web Services . . . . . . . . . . . . . . . . 239 The Role of XML and the Java Platform 240 Overview of the Java APIs for XML 241 JAXP 242 JAX-RPC 250 JAXM 256 JAXR 263 Sample Scenario 265 Chapter 9: Building Web Services With JAX-RPC . . . . . . . . . . 269 Types Supported By JAX-RPC 270 Creating a Web Service with JAX-RPC 272 Creating Web Service Clients with JAX-RPC 276 Further Information 286 Chapter 10: Web Services Messaging with JAXM . . . . . . . . . . 289 The Structure of the JAXM API 290 Overview of JAXM 291 Tutorial 302 Code Examples 323 Conclusion 345 vi CONTENTS Further Information 346 Chapter 11: Publishing and Discovering Web Services with JAXR 347 Overview of JAXR 347 Implementing a JAXR Client 351 Running the Client Examples 371 Further Information 382 Chapter 12: The Coffee Break Application . . . . . . . . . . . . . . . .383 Coffee Break Overview 383 JAX-RPC Distributor Service 385 JAXM Distributor Service 393 Coffee Break Server 401 Deploying and Running the Application 415 Appendix A: Java Encoding Schemes . . . . . . . . . . . . . . . . . . . .425 Further Information 426 Appendix B: HTTP Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . .427 HTTP Requests 428 HTTP Responses 428 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .429 About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . .457 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .459 About This Tutorial THIS tutorial is a beginner’s guide to developing J2EE applications for the Sun™ Open Networking Environment (Sun ONE) platform. Here we cover all the things you need to know to make the best use of this tutorial. Who Should Use This Tutorial This tutorial is intended for programmers interested in developing J2EE applica- tions using the Sun ONE platform. Specifically, it uses the Sun ONE Studio 4, Enterprise Edition for Java to develop J2EE applications and deploy them on Sun ONE Application Server 7. Note: This release of the tutorial includes information on Web applications and Web services. A future release will add coverage of Enterprise JavaBeans technol- ogy and J2EE platform services such as transactions, security, resources, and con- nectors. This tutorial is not a comprehensive introduction to Sun ONE platform software. It focuses on teaching the concepts of J2EE technologies through an extensive set of examples and provides basic instructions in how to use the software so that you can develop, configure, build, deploy, and run the examples. To learn how to use the software, see the resources listed in Further Information (page x). vii viii Prerequisites To understand this tutorial you will need a good knowledge of the Java program- ming language, SQL, and relational database concepts. The topics listed in Table P–1 The Java™ Tutorial are particularly relevant: Table P–1 Relevant Topics in The Java™ Tutorial Topic Web Page JDBC™ http://java.sun.com/docs/books/tutorial/jdbc Threads http://java.sun.com/docs/books/tutorial/essential/threads JavaBeans™ http://java.sun.com/docs/books/tutorial/javabeans How to Read This Tutorial This tutorial is organized into the following sections: • Introduction These chapters introduce the J2EE platform and the fundamentals of Web applications. They are prerequisites for
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents