ebook img

Java Ee Applications on Oracle Java Cloud: Develop, Deploy, Monitor, and Manage Your Java Cloud Applications: Develop, Deploy, Monitor, and Manage Your Java Cloud Applications PDF

290 Pages·2014·6.475 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Java Ee Applications on Oracle Java Cloud: Develop, Deploy, Monitor, and Manage Your Java Cloud Applications: Develop, Deploy, Monitor, and Manage Your Java Cloud Applications

Join the Oracle Press Community at D OraclePressBooks.com ow n lo a d e d b y [ H a c e Find the latest information on Oracle products and tte p e U technologies. Get exclusive discounts on Oracle n iv e Press books. Interact with expert Oracle Press rsity 8 authors and other Oracle Press Community members. 5.2 4 0 Read blog posts, download content and multimedia, .1 2 6 .1 and so much more. Join today! 3 7 ] a t [0 5 Join the Oracle Press Community today /04 /1 6 and get these benefits: ]. C o p y • E xclusive members-only discounts and offers rig h t © • F ull access to all the features on the site: sample M c G chapters, free code and downloads, author blogs, ra w -H podcasts, videos, and more ill G lo • I nteract with authors and Oracle enthusiasts ba l E d u • F ollow your favorite authors and topics and ca tio n receive updates H o ld • N ewsletter packed with exclusive offers and ing s, L discounts, sneak previews, and author podcasts L C . N and interviews o t to b e re d istrib u te d o r m o d ifie d in a n y w a y w ith o u t p e rm @OraclePress issio n . ® Java EE Applications ® on Oracle Java Cloud Develop, Deploy, Monitor, and Manage Your Java Cloud Applications Harshad Oak New York Chicago San Francisco Athens London Madrid Mexico City Milan New Delhi Singapore Sydney Toronto Copyright © 2015 by McGraw-Hill Education (Publisher). All rights reserved. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher, with the exception that the program listings may be entered, stored, and executed in a computer system, but they may not be reproduced for publication. ISBN: 978-0-07-181716-5 MHID: 0-07-181716-6 The material in this eBook also appears in the print version of this title: ISBN: 978-0-07-181715-8, MHID: 0-07-181715-8. eBook conversion by codeMantra Version 1.0 All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark. Where such designations appear in this book, they have been printed with initial caps. McGraw-Hill Education eBooks are available at special quantity discounts to use as premiums and sales promotions or for use in corporate training programs. To contact a representative, please visit the Contact Us page at www.mhprofessional.com. Oracle and Java are registered trademarks of Oracle Corporation and/or its affiliates. All other trademarks are the property of their respective owners, and McGraw-Hill Education makes no claim of ownership by the mention of products that contain these marks. Screen displays of copyrighted Oracle software programs have been reproduced herein with the permission of Oracle Corporation and/or its affiliates. Information has been obtained by Publisher from sources believed to be reliable. However, because of the possibility of human or mechanical error by our sources, Publisher, or others, Publisher does not guarantee to the accuracy, adequacy, or completeness of any information included in this work and is not responsible for any errors or omissions or the results obtained from the use of such information. Oracle Corporation does not make any representations or warranties as to the accuracy, adequacy, or completeness of any information contained in this Work, and is not responsible for any errors or omissions. TERMS OF USE This is a copyrighted work and McGraw-Hill Education and its licensors reserve all rights in and to the work. Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill Education’s prior consent. You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be terminated if you fail to comply with these terms. THE WORK IS PROVIDED “AS IS.” McGRAW-HILL EDUCATION AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill Education and its licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free. Neither McGraw-Hill Education nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom. McGraw-Hill Education has no responsibility for the content of any information accessed through the work. Under no circumstances shall McGraw-Hill Education and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages. This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise. To the two men who shaped me: My father, Achyut (Baba), my pillar of strength, who against great odds ensured that I had a happy upbringing and the gumption to rise. Gandhi, who helped me realize the power of love, truth, and nonviolence. About the Author Harshad Oak is the founder of IndicThreads and Rightrix Solutions. IndicThreads.com is an online developer magazine and hosts some of the most reputable technology conferences in India on topics such as Java, cloud computing, software quality, and mobile software. Before starting his own venture, Harshad was part of i-flex Solutions and Cognizant Technology Solutions. In addition to this work, he has authored Oracle JDeveloper 10g: Empowering J2EE Development and Pro Jakarta Commons, and co-authored J2EE 1.4 Bible. Harshad has spoken at conferences in India, the United States, Sri Lanka, Thailand, and China. He has been working to build active Java communities in India and has organized as well as spoken at many Java user group meetings. Additionally, Harshad teaches Enterprise Java to Master’s candidates in Computer Science at Symbiosis University, India. Harshad has been recognized as an Oracle ACE Director and a Java Champion for his contributions to the technology and the community. Harshad writes about technology on IndicThreads.com and its social streams. He writes about social and other matters at HarshadOak.com and on twitter @HarshadOak. He can be reached at [email protected]. About the Technical Editors Markus Eisele is a software architect, developer, and consultant. He works daily with customers and projects dealing with Enterprise-level Java and infrastructures, including the Java platform and various web-related technologies on a variety of platforms using products from different vendors. An expert in Java EE servers, Markus is an Oracle ACE Director, a Java Champion, and a member of the Java EE 7 expert group, and is a frequent speaker at industry conferences. Follow him on Twitter (@myfear) or read his blog (http://blog.eisele.net). Arun Gupta is Director of Developer Advocacy at Red Hat and focuses on JBoss middleware. He was a founding member of the Java EE team at Sun Microsystems. At Oracle, Arun led a cross-functional team to drive the global launch of the Java EE 7 platform. After authoring approximately 1,400 blogs at blogs.oracle.com/arungupta on different Java technologies, he continues to promote Red Hat technologies and products at blog.arungupta.me. Arun has extensive speaking experience in 35+ countries on myriad topics. Contents at a Glance 1 Java EE and Cloud Computing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 2 The Oracle Java Cloud. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 3 Build and Deploy with NetBeans. . . . . . . . . . . . . . . . . . . . . . . . . . . .49 4 Servlets, Filters, and Listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65 5 JavaServer Pages, JSTL, and Expression Language . . . . . . . . . . . . . . .97 6 JavaServer Faces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127 7 Enterprise JavaBeans (Session Beans). . . . . . . . . . . . . . . . . . . . . . . .151 8 Web Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179 9 Persistence Using the Oracle Database Cloud Service. . . . . . . . . . .203 A Java EE Technologies and JSRs . . . . . . . . . . . . . . . . . . . . . . . . . . . . .233 B Application Servers Compatible with Java EE 5, 6, and 7. . . . . . . . .243 C Supported and Unsupported Technologies, Services, and APIs . . . .247 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 v This page intentionally left blank Contents Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix 1 Java EE and Cloud Computing . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Java Editions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Java EE Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Application Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Open Source vs. Commercial . . . . . . . . . . . . . . . . . . . . . . 4 Reference Implementation . . . . . . . . . . . . . . . . . . . . . . . . 6 API and Technology Specification . . . . . . . . . . . . . . . . . . . . . . . . 7 Java Community Process (JCP) and Java EE . . . . . . . . . . . . 8 Java EE Compatible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Web Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Cloud Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Going Around in Circles . . . . . . . . . . . . . . . . . . . . . . . . . . 11 What Is Cloud Computing? . . . . . . . . . . . . . . . . . . . . . . . . 12 Why Cloud Computing? . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Concerns About Cloud Computing . . . . . . . . . . . . . . . . . . 15 Private, Public, and Hybrid Clouds . . . . . . . . . . . . . . . . . . 16 Cloud as a Leveler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Java EE on the Cloud . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Competing Technologies: Alternatives to Java on the Cloud . . . . . . . . . . . . . . . . . . . . . . . . . 17 vii viii Java EE Applications on Oracle Java Cloud Standards and Java EE 7 . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Java EE Vendors and Alternatives . . . . . . . . . . . . . . . . . . . . 19 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2 The Oracle Java Cloud . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Oracle’s Cloud Foray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Oracle Cloud Constituents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 SaaS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 IaaS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 PaaS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Java Cloud . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Pricing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Trial Signup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 My Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 IDE Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Oracle Java Cloud Service SDK . . . . . . . . . . . . . . . . . . . . . 36 Users and Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 3 Build and Deploy with NetBeans . . . . . . . . . . . . . . . . . . . . . . . . 49 Development IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Why NetBeans? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Building with Java EE Technologies . . . . . . . . . . . . . . . . . . . . . . . 51 First NetBeans Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 What Happened? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Files and Directories Generated . . . . . . . . . . . . . . . . . . . . 58 The Cloud Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Clean and Build, Verify . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Web Application Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Packaging the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 We Are at WAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 4 Servlets, Filters, and Listeners . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Servlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Servlet Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 HttpServlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Servlet One . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Servlet Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.