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
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
Contents ix HttpServletRequest... 73 HttpServletResponse... 73 web.xml... 73 weblogic.xml... 75 Sharing Data... 75 Session Management... 79 HttpSession... 79 RequestDispatcher... 80 WebLogic-Specific Servlet Capabilities on OJC... 82 Filters... 83 Listeners... 86 View Java Logs... 91 Summary... 95 5 JavaServer Pages, JSTL, and Expression Language... 97 The Origin of JSP... 98 JSP on the Oracle Java Cloud... 99 JSP Internals... 100 JSP Lifecycle... 100 Servlet Code... 101 JSP Directives... 105 JSP Declaration... 107 JSP Scriptlets... 107 JSP Expressions... 108 Implicit Objects... 109 JSP Comments... 110 Tags and Expressions... 111 Custom Tags... 112 Expression Language... 113 JSTL Libraries... 114 Using Tags in a JSP... 120 Summary... 126 6 JavaServer Faces... 127 From JSP to Struts to JSF... 128 JSF on the Oracle Java Cloud... 129 Facelets... 129 JSF Managed Beans... 134 Validation... 142 Ajax... 145
x Java EE Applications on Oracle Java Cloud Templates... 146 Summary... 150 7 Enterprise JavaBeans (Session Beans)... 151 Containers... 152 EJB in OJC... 153 Why EJB?... 153 Session Beans... 154 Stateless... 155 Stateful... 155 Interfaces: Local or Remote... 155 Developing an Enterprise Application with EJBs... 157 New Session Bean... 159 Inject the Session Bean into the Servlet... 163 Package and Run from NetBeans... 164 Deploy Using the Java Cloud Services Control... 164 Lifecycle of a Session Bean... 169 Transaction Management... 171 Rollback and Exception Handling... 176 Summary... 177 8 Web Services... 179 Developing a SOAP Web Service... 181 WSDL... 186 Web Service Client... 187 RESTful Web Services Using JAX-RS API... 194 Building RESTful Web Services on the OJC... 195 JAX-RS 1.1 Fix... 196 Modify the REST Resource... 197 RESTful Web Service Client... 199 Summary... 202 9 Persistence Using the Oracle Database Cloud Service... 203 Persistence on the Oracle Cloud... 204 Oracle Database Cloud Service... 204 Explore Database Cloud... 205 Oracle Apex................................... 210 Java Cloud: Database Cloud Integration... 211 JPA... 212 Persistence Providers... 213 Entity... 213
Contents xi Developing an Entity Application... 214 Add Entity from a Servlet... 219 Find and Update Entity... 222 Java Persistence Query Language... 223 CRUD JSF for Entity... 229 Summary... 232 A Java EE Technologies and JSRs... 233 Java Platform, Enterprise Edition 5 (Java EE 5) JSR 244... 234 Java Platform, Enterprise Edition 6 (Java EE 6) JSR 316... 235 Java Platform, Enterprise Edition 6 (Java EE 6) Web Profile... 237 Java Platform, Enterprise Edition 7 (Java EE 7) JSR 342... 238 Java Platform, Enterprise Edition 7 (Java EE 7) Web Profile... 241 B Application Servers Compatible with Java EE 5, 6, and 7... 243 Java EE 5 Compatible Implementations... 244 Java EE 6 Full Platform Compatible Implementations... 245 Java EE 6 Web Profile Compatible Implementations... 245 Java EE 7 Full Platform Compatible Implementations... 246 Java EE 7 Web Profile Compatible Implementations... 246 C Supported and Unsupported Technologies, Services, and APIs.. 247 Technologies and Services Supported... 248 Java EE 5 and 6 Specifications Supported... 248 Public WebLogic Server 10.3.6 APIs and Capabilities Supported... 249 Unsupported Features and APIs... 250 Unsupported WebLogic Server 10.3.6 APIs and Capabilities... 251 Whitelist Violations... 252 Index... 253