1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu The Java EE Tutorial For Sun Java System Application Server 9.1 pptx

1,1K 15,9K 2

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1.124
Dung lượng 9,66 MB

Nội dung

The Java EE Tutorial For Sun Java System Application Server 9.1 Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054 U.S.A. Part No: 819–3669–10 September 2007 Copyright 2007 Sun Microsystems, Inc. 4150 Network Circle, Santa Clara, CA 95054 U.S.A. All rights reserved. Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is described in this document. In particular, and without limitation, these intellectual property rights may include one or more U.S. patents or pending patent applications in the U.S. and in other countries. 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 supplements. This distribution may include materials developed by third parties. Parts of the product may be derived from Berkeley BSD systems, licensed from the University of California. UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company, Ltd. Sun, Sun Microsystems, the Sun logo, the Solaris logo, the Java Coee Cup logo, docs.sun.com, Java, and Solaris are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the U.S. and other countries. Products bearing SPARC trademarks are based upon an architecture developed by Sun Microsystems, Inc. The OPEN LOOK and Sun TM Graphical User Interface was developed by Sun Microsystems, Inc. for its users and licensees. Sun acknowledges the pioneering eorts of Xerox in researching and developing the concept of visual or graphical user interfaces for the computer industry. Sun holds a non-exclusive license from Xerox to the Xerox Graphical User Interface, which license also covers Sun's licensees who implement OPEN LOOK GUIs and otherwise comply with Sun's written license agreements. Products covered by and information contained in this publication are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical or biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identied 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 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID. Copyright 2007 Sun Microsystems, Inc. 4150 Network Circle, Santa Clara, CA 95054 U.S.A. Tous droits réservés. Sun Microsystems, Inc. détient les droits de propriété intellectuelle relatifs à la technologie incorporée dans le produit qui est décrit dans ce document. En particulier, et ce sans limitation, ces droits de propriété intellectuelle peuvent inclure un ou plusieurs brevets américains ou des applications de brevet en attente aux Etats-Unis et dans d'autres pays. Cette distribution peut comprendre des composants développés par des tierces personnes. Certaines composants de ce produit peuvent être dérivées du logiciel Berkeley BSD, licenciés par l'Université de Californie. UNIX est une marque déposée aux Etats-Unis et dans d'autres pays; elle est licenciée exclusivement par X/Open Company, Ltd. Sun, Sun Microsystems, le logo Sun, le logo Solaris, le logo Java Coee Cup, docs.sun.com, Java et Solaris sont des marques de fabrique ou des marques déposées de Sun Microsystems, Inc. aux Etats-Unis et dans d'autres pays. Toutes les marques SPARC sont utilisées sous licence et sont des marques de fabrique ou des marques déposées de SPARCInternational, Inc. aux Etats-Unis et dans d'autres pays. Les produits portant les marques SPARC sont basés sur une architecture développée par Sun Microsystems, Inc. L'interface d'utilisation graphique OPEN LOOK et Sun a été développée par Sun Microsystems, Inc. pour ses utilisateurs et licenciés. Sun reconnaît les eorts de pionniers de Xerox pour la recherche et le développement du concept des interfaces d'utilisation visuelle ou graphique pour l'industrie de l'informatique. Sun détient une licence non exclusive de Xerox sur l'interface d'utilisation graphique Xerox, cette licence couvrant également les licenciés de Sun qui mettent en place l'interface d'utilisation graphique OPEN LOOK et qui, en outre, se conforment aux licences écrites de Sun. Les produits qui font l'objet de cette publication et les informations qu'il contient sont régis par la legislation 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 nales, ou utilisateurs naux, pour des armes nucléaires, des missiles, des armes chimiques ou biologiques ou pour le nucléaire maritime, directement ou indirectement, sont strictement interdites. Les exportations ou réexportations vers des pays sous embargo des Etats-Unis, ou vers des entités gurant 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 participer, d'une façon directe ou indirecte, aux exportations des produits ou des services qui sont régis par la legislation américaine en matière de contrôle des exportations et la liste de ressortissants spéciquement designés, sont rigoureusement interdites. LA DOCUMENTATION EST FOURNIE "EN L'ETAT" ET TOUTES AUTRES CONDITIONS, DECLARATIONS 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 CONTREFACON. 070913@18741 Contents Preface 29 Part I Introduction 39 1 Overview 41 Java EE Application Model 42 Distributed Multitiered Applications 42 Security 43 Java EE Components 44 Java EE Clients 44 Web Components 46 Business Components 47 Enterprise Information System Tier 48 Java EE Containers 48 Container Services 49 Container Types 49 Web Services Support 51 XML 51 SOAP Transport Protocol 52 WSDL Standard Format 52 UDDI and ebXML Standard Formats 52 Java EE Application Assembly and Deployment 52 Packaging Applications 53 Development Roles 54 Java EE Product Provider 55 Tool Provider 55 Application Component Provider 55 3 Application Assembler 56 Application Deployer and Administrator 56 Java EE 5 APIs 57 Enterprise JavaBeans Technology 57 Java Servlet Technology 58 JavaServer Pages Technology 58 JavaServer Pages Standard Tag Library 58 JavaServer Faces 58 Java Message Service API 59 Java Transaction API 59 JavaMail API 59 JavaBeans Activation Framework 59 Java API for XML Processing 60 Java API for XML Web Services (JAX-WS) 60 Java Architecture for XML Binding (JAXB) 60 SOAP with Attachments API for Java 60 Java API for XML Registries 61 J2EE Connector Architecture 61 Java Database Connectivity API 61 Java Persistence API 62 Java Naming and Directory Interface 62 Java Authentication and Authorization Service 62 Simplied Systems Integration 63 Sun Java System Application Server Platform Edition 9 63 Tools 63 2 Using theTutorial Examples 65 Required Software 65 Tutorial Bundle 65 Java Platform, Standard Edition 66 Sun Java System Application Server 9.1 66 NetBeans IDE 67 Apache Ant 68 Starting and Stopping the Application Server 68 Starting the Admin Console 69 Contents The Java EE Tutorial • September 20074 Starting and Stopping the Java DB Database Server 69 Building the Examples 70 Building the Examples Using NetBeans IDE 70 Building the Examples on the Command-Line Using Ant 70 Tutorial Example Directory Structure 71 Debugging Java EE Applications 72 Using the Server Log 72 Using a Debugger 73 Part II TheWeb Tier 75 3 Getting Started withWeb Applications 77 Web Applications 77 Web Application Life Cycle 80 Web Modules 81 Packaging Web Modules 83 Deploying a WAR File 84 Testing Deployed Web Modules 85 Listing Deployed Web Modules 86 Updating Web Modules 86 Undeploying Web Modules 88 Conguring Web Applications 89 Mapping URLs to Web Components 89 Declaring Welcome Files 91 Setting Initialization Parameters 92 Mapping Errors to Error Screens 93 Declaring Resource References 94 Duke’s Bookstore Examples 96 Accessing Databases from Web Applications 97 Populating the Example Database 97 Creating a Data Source in the Application Server 98 Further Information about Web Applications 98 Contents 5 4 Java Servlet Technology 99 What Is a Servlet? 99 The Example Servlets 100 Troubleshooting Duke's Bookstore Database Problems 102 Servlet Life Cycle 102 Handling Servlet Life-Cycle Events 103 Handling Servlet Errors 105 Sharing Information 105 Using Scope Objects 105 Controlling Concurrent Access to Shared Resources 106 Accessing Databases 107 Initializing a Servlet 109 Writing Service Methods 110 Getting Information from Requests 110 Constructing Responses 112 Filtering Requests and Responses 114 Programming Filters 115 Programming Customized Requests and Responses 117 Specifying Filter Mappings 119 Invoking Other Web Resources 122 Including Other Resources in the Response 122 Transferring Control to Another Web Component 124 Accessing the Web Context 124 Maintaining Client State 125 Accessing a Session 125 Associating Objects with a Session 126 Session Management 126 Session Tracking 127 Finalizing a Servlet 128 Tracking Service Requests 129 Notifying Methods to Shut Down 129 Creating Polite Long-Running Methods 130 Further Information about Java Servlet Technology 131 Contents The Java EE Tutorial • September 20076 5 JavaServer PagesTechnology 133 What Is a JSP Page? 133 A Simple JSP Page Example 134 The Example JSP Pages 136 The Life Cycle of a JSP Page 142 Translation and Compilation 142 Execution 143 Creating Static Content 144 Response and Page Encoding 145 Creating Dynamic Content 145 Using Objects within JSP Pages 145 Unied Expression Language 146 Immediate and Deferred Evaluation Syntax 148 Value and Method Expressions 150 Dening a Tag Attribute Type 156 Deactivating Expression Evaluation 157 Literal Expressions 158 Resolving Expressions 160 Implicit Objects 162 Operators 163 Reserved Words 163 Examples of EL Expressions 164 Functions 165 JavaBeans Components 167 JavaBeans Component Design Conventions 167 Creating and Using a JavaBeans Component 168 Setting JavaBeans Component Properties 169 Retrieving JavaBeans Component Properties 171 Using Custom Tags 172 Declaring Tag Libraries 172 Including the Tag Library Implementation 174 Reusing Content in JSP Pages 175 Transferring Control to Another Web Component 176 jsp:param Element 176 Including an Applet 176 Setting Properties for Groups of JSP Pages 179 Contents 7 Deactivating EL Expression Evaluation 180 Further Information about JavaServer Pages Technology 183 6 JavaServer Pages Documents 185 The Example JSP Document 185 Creating a JSP Document 188 Declaring Tag Libraries 190 Including Directives in a JSP Document 191 Creating Static and Dynamic Content 193 Using the jsp:root Element 196 Using the jsp:output Element 196 Identifying the JSP Document to the Container 200 7 JavaServer Pages Standard Tag Library 201 The Example JSP Pages 201 Using JSTL 203 Tag Collaboration 204 Core Tag Library 205 Variable Support Tags 205 Flow Control Tags 206 URL Tags 210 Miscellaneous Tags 211 XML Tag Library 211 Core Tags 213 Flow Control Tags 214 Transformation Tags 215 Internationalization Tag Library 215 Setting the Locale 216 Messaging Tags 216 Formatting Tags 217 SQL Tag Library 218 query Tag Result Interface 220 JSTL Functions 222 Further Information about JSTL 223 Contents The Java EE Tutorial • September 20078 8 CustomTags in JSP Pages 225 What Is a Custom Tag? 226 The Example JSP Pages 226 Types of Tags 229 Tags with Attributes 229 Tags with Bodies 232 Tags That Dene Variables 232 Communication between Tags 233 Encapsulating Reusable Content Using Tag Files 233 Tag File Location 235 Tag File Directives 235 Evaluating Fragments Passed to Tag Files 242 Custom Tag Examples 243 Tag Library Descriptors 247 Top-Level Tag Library Descriptor Elements 248 Declaring Tag Files 249 Declaring Tag Handlers 251 Declaring Tag Attributes for Tag Handlers 252 Declaring Tag Variables for Tag Handlers 254 Programming Simple Tag Handlers 256 Including Tag Handlers in Web Applications 256 How Is a Simple Tag Handler Invoked? 256 Tag Handlers for Basic Tags 257 Tag Handlers for Tags with Attributes 257 Tag Handlers for Tags with Bodies 260 Tag Handlers for Tags That Dene Variables 261 Cooperating Tags 263 Tag Handler Examples 265 9 Scripting in JSP Pages 273 The Example JSP Pages 273 Using Scripting 275 Disabling Scripting 275 JSP Declarations 276 Initializing and Finalizing a JSP Page 276 Contents 9 JSP Scriptlets 277 JSP Expressions 277 Programming Tags That Accept Scripting Elements 278 TLD Elements 278 Tag Handlers 278 Tags with Bodies 280 Cooperating Tags 282 Tags That Dene Variables 284 10 JavaServer FacesTechnology 285 JavaServer Faces Technology User Interface 285 JavaServer Faces Technology Benets 286 What Is a JavaServer Faces Application? 287 A Simple JavaServer Faces Application 287 Steps in the Development Process 288 Mapping the FacesServlet Instance 289 Creating the Pages 290 Dening Page Navigation 296 Conguring Error Messages 297 Developing the Beans 298 Adding Managed Bean Declarations 298 User Interface Component Model 299 User Interface Component Classes 300 Component Rendering Model 301 Conversion Model 304 Event and Listener Model 305 Validation Model 307 Navigation Model 307 Backing Beans 309 Creating a Backing Bean Class 309 The Life Cycle of a JavaServer Faces Page 313 Restore View Phase 315 Further Information about JavaServer Faces Technology 318 Contents The Java EE Tutorial • September 200710 [...]... (Java EE platform) applications intended to run on the Application Server that follow the open Java standards model for Java EE components and APIs Includes information about developer tools, security, debugging, and creating lifecycle modules Java EE 5 Tutorial Using Java EE 5 platform technologies and APIs to develop Java EE applications Java WSIT Tutorial Developing web applications using the Web... directory for the Java Platform, Standard Edition (Java SE platform) None Same value as the JAVA_ HOME environment variable as-install Represents the base installation directory for the Application Server or the Software Development Kit (SDK) of which the Application Server is a part Java ES installations on the SolarisTM operating system: /opt/SUNWappserver/appserver Java ES installations on the Linux... packages provided with the Application Server is located at http://glassfish.dev .java. net/nonav/javaee5/api/index.html Additionally, the following resources might be useful: ■ ■ The Java EE 5 Specifications (http:/ /java. sun. com/javaee/5/javatech.html) The Java EE Blueprints (http:/ /java. sun. com/reference/blueprints/index.html) For information on creating enterprise applications in the NetBeansTM Integrated... Bank Application describes an application that employs web application technologies, enterprise beans, and the Java Persistence API Finally, Part VIII contains information about Java encoding schemes and Java EE certification that may be helpful to the Java EE 5 application developer, and information about the tutorial' s authors 31 Preface Application Server Documentation Set The Application Server. .. 1086 C About the Authors 1089 Index 1091 27 28 Preface This tutorial is a guide to developing enterprise applications for the JavaTM Platform, Enterprise Edition 5 (Java EE 5) This preface contains information about and conventions for the entire Sun Java System Application Server documentation set Before You Read This Book Before proceeding with this tutorial, you... see http://www.netbeans.org/kb/55/index.html For information about the Java DB database included with the Application Server, see http://developers .sun. com/javadb/ The GlassFish Samples project is a collection of sample applications that demonstrate a broad range of Java EE technologies The GlassFish Samples are bundled with the Java EE Software Development Kit (SDK), and are also available from the. .. The Java Persistence Query Language The platform services chapters in Part VI cover the system services used by all the Java EE 5 component technologies: ■ ■ ■ ■ ■ 30 Session beans Message-driven beans The persistence technology chapters in Part V cover the Java Persistence API, which is used for accessing databases from Java EE applications: ■ ■ The Java API for XML-based Web Services (JAX-WS) The Java. .. architecture and APIs, the Sun Java System Application Server 9.1, and how to use the this tutorial' s examples When you have digested the basics, you can delve into one or more of the five main technology areas listed next Because there are dependencies between some of the chapters, Figure P–1 contains a roadmap for navigating through the tutorialThe web-tier technology chapters in Part II cover the components... deployment planning and system installation The Uniform Resource Locator (URL) for Application Server documentation is http://docs .sun. com/coll/1343.4 For an introduction to Application Server, refer to the books in the order in which they are listed in the following table TABLE P–1 Books in the Application Server Documentation Set Book Title Description Documentation Center Application Server documentation... Building, Packaging, and Deploying the SAAJ Coffee Supplier Service 1053 Building, Packaging, and Deploying the Coffee Break Server 1053 Running the Coffee Break Client 1054 Removing the Coffee Break Application 1056 37 The Duke’s Bank Application 1057 Overview of the Duke’s Bank Application 1057 26 The Java EE Tutorial • September 2007 Contents . The Java EE Tutorial For Sun Java System Application Server 9. 1 Sun Microsystems, Inc. 415 0 Network Circle Santa Clara, CA 95 054 U.S.A. Part No: 8 19 36 69 10 September. September 200 710 11 Using JavaServer FacesTechnology in JSP Pages 3 19 The Example JavaServer Faces Application 3 19 Setting Up a Page 322 Using the Core Tags

Ngày đăng: 20/01/2014, 04:20

TỪ KHÓA LIÊN QUAN

w