No Title

Embed or link this publication

Popular Pages


p. 1

the java ee 6 tutorial oracle corporation 500 oracle parkway redwood city ca 94065 u.s.a part no 821­1841­13 july 2011

[close]

p. 2

copyright © 2011 oracle and/or its affiliates all rights reserved copyright and license the java ee 6 tutorial this tutorial is a guide to developing applications for the java platform enterprise edition and contains documentation tutorial and sample code the sample code made available with this tutorial is licensed separately to you by oracle under the berkeley license if you download any such sample code you agree to the terms of the berkeley license this tutorial is provided to you by oracle under the following license terms containing restrictions on use and disclosure and is protected by intellectual property laws oracle grants to you a limited non-exclusive license to use this tutorial for information purposes only as an aid to learning about the java ee platform except as expressly permitted in these license terms you may not use copy reproduce translate broadcast modify license transmit distribute exhibit perform publish or display any part in any form or by any means this tutorial reverse engineering disassembly or decompilation of this tutorial is prohibited the information contained herein is subject to change without notice and is not warranted to be error-free if you find any errors please report them to us in writing if the tutorial is licensed on behalf of the u.s government the following notice is applicable u.s government rights programs software databases and related documentation and technical data delivered to u.s government customers are commercial computer software or commercial technical data pursuant to the applicable federal acquisition regulation and agency-specific supplemental regulations as such the use duplication disclosure modification and adaptation shall be subject to the restrictions and license terms set forth in the applicable government contract and to the extent applicable by the terms of the government contract the additional rights set forth in far 52.227-19 commercial computer software license december 2007 oracle usa inc 500 oracle parkway redwood city ca 94065 this tutorial is not developed or intended for use in any inherently dangerous applications including applications which may create a risk of personal injury if you use this tutorial in dangerous applications then you shall be responsible to take all appropriate fail-safe backup redundancy and other measures to ensure the safe use the tutorial is provided as is without warranty of any kind oracle further disclaims all warranties express and implied including without limitation any implied warranties of merchantability fitness for a particular purpose or noninfringement in no event shall oracle be liable for any indirect incidental special punitive or consequential damages or damages for loss of profits revenue data or data use incurred by you or any third party whether in an action in contract or tort even if oracle has been advised of the possibility of such damages oracle s entire liability for damages hereunder shall in no event exceed one thousand dollars u.s $1,000 no technical support oracle s technical support organization will not provide technical support phone support or updates to you oracle and java are registered trademarks of oracle and/or its affiliates other names may be trademarks of their respective owners the sample code and tutorial may provide access to or information on content products and services from third parties oracle corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content products and services oracle corporation and its affiliates will not be responsible for any loss costs or damages incurred due to your access to or use of third-party content products or services 110727@25097

[close]

p. 3

contents preface 29 part i introduction 33 1 overview 35 java ee 6 platform highlights 36 java ee application model 37 distributed multitiered applications 37 security 39 java ee components 40 java ee clients 40 web components 42 business components 43 enterprise information system tier 44 java ee containers 45 container services 45 container types 46 web services support 47 xml 47 soap transport protocol 48 wsdl standard format 48 java ee application assembly and deployment 48 packaging applications 49 development roles 50 java ee product provider 51 tool provider 51 application component provider 51 3

[close]

p. 4

contents application assembler 52 application deployer and administrator 52 java ee 6 apis 53 enterprise javabeans technology 56 java servlet technology 57 javaserver faces technology 57 javaserver pages technology 58 javaserver pages standard tag library 58 java persistence api 59 java transaction api 59 java api for restful web services 59 managed beans 59 contexts and dependency injection for the java ee platform jsr 299 60 dependency injection for java jsr 330 60 bean validation 60 java message service api 60 java ee connector architecture 60 javamail api 61 java authorization contract for containers 61 java authentication service provider interface for containers 61 java ee 6 apis in the java platform standard edition 6.0 62 java database connectivity api 62 java naming and directory interface api 62 javabeans activation framework 63 java api for xml processing 63 java architecture for xml binding 63 soap with attachments api for java 64 java api for xml web services 64 java authentication and authorization service 64 glassfish server tools 64 2 using the tutorial examples 67 required software 67 java platform standard edition 67 java ee 6 software development kit 68 4 the java ee 6 tutorial · july 2011

[close]

p. 5

contents java ee 6 tutorial component 68 netbeans ide 69 apache ant 70 starting and stopping the glassfish server 71 starting the administration console 72 to start the administration console in netbeans ide 72 starting and stopping the java db server 72 to start the database server using netbeans ide 72 building the examples 73 tutorial example directory structure 73 getting the latest updates to the tutorial 74 to update the tutorial through the update center 74 debugging java ee applications 74 using the server log 74 using a debugger 75 part ii the web tier 77 3 getting started with web applications 79 web applications 79 web application lifecycle 81 web modules the hello1 example 82 examining the hello1 web module 83 packaging a web module 86 deploying a web module 87 running a deployed web module 88 listing deployed web modules 88 updating a web module 89 dynamic reloading 89 undeploying web modules 90 configuring web applications the hello2 example 91 mapping urls to web components 91 examining the hello2 web module 91 building packaging deploying and running the hello2 example 93 declaring welcome files 94 5

[close]

p. 6

contents setting context and initialization parameters 95 mapping errors to error screens 97 declaring resource references 98 further information about web applications 100 4 javaserver faces technology 101 what is a javaserver faces application 102 javaserver faces technology benefits 103 creating a simple javaserver faces application 104 developing the managed bean 104 creating the web page 105 mapping the facesservlet instance 106 the lifecycle of the hello application 106 to build package deploy and run the hello application in netbeans ide 107 to build package deploy and run the hello example using ant 108 further information about javaserver faces technology 108 5 introduction to facelets 111 what is facelets 111 developing a simple facelets application 113 creating a facelets application 113 configuring the application 116 building packaging deploying and running the guessnumber facelets example 117 templating 119 composite components 121 resources 123 6 expression language 125 overview of the el 125 immediate and deferred evaluation syntax 126 immediate evaluation 127 deferred evaluation 127 value and method expressions 128 value expressions 128 6 the java ee 6 tutorial · july 2011

[close]

p. 7

contents method expressions 132 defining a tag attribute type 134 literal expressions 135 operators 136 reserved words 136 examples of el expressions 137 7 using javaserver faces technology in web pages 139 setting up a page 139 adding components to a page using html tags 140 common component tag attributes 143 adding html head and body tags 145 adding a form component 145 using text components 146 using command component tags for performing actions and navigation 151 adding graphics and images with the h:graphicimage tag 153 laying out components with the h:panelgrid and h:panelgroup tags 153 displaying components for selecting one value 155 displaying components for selecting multiple values 157 using the f:selectitem and f:selectitems tags 158 using data-bound table components 160 displaying error messages with the h:message and h:messages tags 163 creating bookmarkable urls with the h:button and h:link tags 164 using view parameters to configure bookmarkable urls 164 resource relocation using h:output tags 165 using core tags 167 8 using converters listeners and validators 171 using the standard converters 171 converting a component s value 172 using datetimeconverter 173 using numberconverter 175 registering listeners on components 176 registering a value-change listener on a component 177 registering an action listener on a component 178 7

[close]

p. 8

contents using the standard validators 178 validating a component s value 179 using longrangevalidator 180 referencing a managed bean method 180 referencing a method that performs navigation 181 referencing a method that handles an action event 181 referencing a method that performs validation 181 referencing a method that handles a value-change event 182 9 developing with javaserver faces technology 183 managed beans 183 creating a managed bean 184 using the el to reference managed beans 185 writing bean properties 186 writing properties bound to component values 187 writing properties bound to component instances 192 writing properties bound to converters listeners or validators 193 writing managed bean methods 194 writing a method to handle navigation 194 writing a method to handle an action event 196 writing a method to perform validation 196 writing a method to handle a value-change event 197 using bean validation 198 validating null and empty strings 201 10 javaserver faces technology advanced concepts 203 overview of the javaserver faces lifecycle 204 the lifecycle of a javaserver faces application 204 restore view phase 207 apply request values phase 207 process validations phase 208 update model values phase 208 invoke application phase 209 render response phase 209 partial processing and partial rendering 210 the java ee 6 tutorial · july 2011 8

[close]

p. 9

contents the lifecycle of a facelets application 210 user interface component model 211 user interface component classes 211 component rendering model 213 conversion model 214 event and listener model 215 validation model 216 navigation model 217 11 configuring javaserver faces applications 221 using annotations to configure managed beans 222 using managed bean scopes 222 application configuration resource file 223 ordering of application configuration resource files 224 configuring beans 226 using the managed-bean element 227 initializing properties using the managed-property element 229 initializing maps and lists 234 registering custom error messages 234 using facesmessage to create a message 235 referencing error messages 235 registering custom localized static text 237 using default validators 238 configuring navigation rules 238 implicit navigation rules 241 basic requirements of a javaserver faces application 241 configuring an application with a web deployment descriptor 242 configuring project stage 245 including the classes pages and other resources 246 12 using ajax with javaserver faces technology 247 overview of ajax 248 using ajax functionality with javaserver faces technology 248 using ajax with facelets 249 using the f:ajax tag 249 9

[close]

p. 10

contents sending an ajax request 251 using the event attribute 251 using the execute attribute 252 using the immediate attribute 252 using the listener attribute 253 monitoring events on the client 253 handling errors 254 receiving an ajax response 254 ajax request lifecycle 255 grouping of components 256 loading javascript as a resource 256 using javascript api in a facelets application 257 using the @resourcedependency annotation in a bean class 258 the ajaxguessnumber example application 258 the ajaxguessnumber source files 259 building packaging deploying and running the ajaxguessnumber example 260 further information about ajax in javaserver faces 262 13 advanced composite components 263 attributes of a composite component 263 invoking a managed bean 264 validating composite component values 265 the compositecomponentlogin example application 265 the composite component file 265 the using page 266 the managed bean 267 building packaging deploying and running the compositecomponentlogin example 268 14 creating custom ui components 271 determining whether you need a custom component or renderer 272 when to use a custom component 272 when to use a custom renderer 273 component renderer and tag combinations 274 steps for creating a custom component 275 the java ee 6 tutorial · july 2011 10

[close]

p. 11

contents creating custom component classes 275 specifying the component family 277 performing encoding 277 performing decoding 278 enabling component properties to accept expressions 279 saving and restoring state 280 delegating rendering to a renderer 281 creating the renderer class 281 identifying the renderer type 282 handling events for custom components 282 creating the component tag handler 282 retrieving the component type 283 setting component property values 283 providing the renderer type 284 releasing resources 285 defining the custom component tag in a tag library descriptor 285 creating a custom converter 286 implementing an event listener 288 implementing value-change listeners 289 implementing action listeners 290 creating a custom validator 291 implementing the validator interface 292 creating a custom tag 295 using custom objects 296 using a custom converter 297 using a custom validator 298 using a custom component 299 binding component values and instances to external data sources 300 binding a component value to a property 302 binding a component value to an implicit object 302 binding a component instance to a bean property 303 binding converters listeners and validators to managed bean properties 304 15 java servlet technology 307 what is a servlet 308 11

[close]

p. 12

contents servlet lifecycle 308 handling servlet lifecycle events 308 handling servlet errors 310 sharing information 310 using scope objects 310 controlling concurrent access to shared resources 311 creating and initializing a servlet 311 writing service methods 312 getting information from requests 312 constructing responses 313 filtering requests and responses 314 programming filters 315 programming customized requests and responses 316 specifying filter mappings 316 invoking other web resources 318 including other resources in the response 319 transferring control to another web component 319 accessing the web context 319 maintaining client state 320 accessing a session 320 associating objects with a session 320 session management 321 session tracking 321 finalizing a servlet 322 tracking service requests 322 notifying methods to shut down 323 creating polite long-running methods 323 the mood example application 324 components of the mood example application 324 building packaging deploying and running the mood example 325 further information about java servlet technology 326 16 internationalizing and localizing web applications 327 java platform localization classes 327 providing localized messages and labels 328 12 the java ee 6 tutorial · july 2011

[close]

p. 13

contents establishing the locale 328 setting the resource bundle 329 retrieving localized messages 330 date and number formatting 331 character sets and encodings 331 character sets 331 character encoding 332 part iii web services 335 17 introduction to web services 337 what are web services 337 types of web services 337 big web services 338 restful web services 338 deciding which type of web service to use 340 18 building web services with jax-ws 341 creating a simple web service and clients with jax-ws 342 requirements of a jax-ws endpoint 343 coding the service endpoint implementation class 344 building packaging and deploying the service 344 testing the methods of a web service endpoint 345 a simple jax-ws application client 346 a simple jax-ws web client 348 types supported by jax-ws 351 schema-to-java mapping 351 java-to-schema mapping 352 web services interoperability and jax-ws 353 further information about jax-ws 353 19 building restful web services with jax-rs 355 what are restful web services 355 creating a restful root resource class 356 13

[close]

p. 14

contents developing restful web services with jax-rs 356 overview of a jax-rs application 358 the @path annotation and uri path templates 359 responding to http methods and requests 361 using @consumes and @produces to customize requests and responses 364 extracting request parameters 366 example applications for jax-rs 370 a restful web service 370 the rsvp example application 372 real-world examples 374 further information about jax-rs 375 20 advanced jax-rs features 377 annotations for field and bean properties of resource classes 377 extracting path parameters 378 extracting query parameters 379 extracting form data 379 extracting the java type of a request or response 380 subresources and runtime resource resolution 380 subresource methods 381 subresource locators 381 integrating jax-rs with ejb technology and cdi 382 conditional http requests 383 runtime content negotiation 384 using jax-rs with jaxb 386 21 running the advanced jax-rs example application 387 the customer example application 387 the customer application source files 387 the customerservice class 387 the xsd schema for the customer application 389 the customerclient class 389 building packaging deploying and running the customer example 391 14 the java ee 6 tutorial · july 2011

[close]

p. 15

contents part iv enterprise beans 395 22 enterprise beans 397 what is an enterprise bean 397 benefits of enterprise beans 398 when to use enterprise beans 398 types of enterprise beans 398 what is a session bean 399 types of session beans 399 when to use session beans 400 what is a message-driven bean 401 what makes message-driven beans different from session beans 401 when to use message-driven beans 402 accessing enterprise beans 403 using enterprise beans in clients 403 deciding on remote or local access 404 local clients 405 remote clients 407 web service clients 408 method parameters and access 409 the contents of an enterprise bean 409 packaging enterprise beans in ejb jar modules 409 packaging enterprise beans in war modules 410 naming conventions for enterprise beans 411 the lifecycles of enterprise beans 412 the lifecycle of a stateful session bean 412 the lifecycle of a stateless session bean 413 the lifecycle of a singleton session bean 413 the lifecycle of a message-driven bean 414 further information about enterprise beans 415 23 getting started with enterprise beans 417 creating the enterprise bean 417 coding the enterprise bean class 418 creating the converter web client 418 15

[close]

Comments

no comments yet