Build an online messaging app using Java Servlets, JSP, Expression Language, JSTL, JPQL, Sessions/Cookies, HTML/CSS/JavaScript, and the Bootstrap framework. This book explains Java EE, along with its associated technologies making it perfect for those with at least basic programming experience in Java or C. __Java EE Web Application Primer__ teaches you how to develop complete web applications using Oracle as the database. By the end of the book you will have developed an online messaging app like Twitter. From there you can create other applications such as an online survey tool. **What You'll Learn** * Build a Twitter-like web application called Bullhorn using Java, Oracle, and more * Create web applications using Eclipse * Design web pages with HTML forms, tables, and more * Use SQL along with Java and Oracle for database accessibility * Connect to a database using the Java Persistence APIs * Create dynamic web pages with JavaScript, JSP, and the tag libraries * Get web pages to stand out with Bootstrap, jQuery, and CSS **Who This Book Is For** Those with at least basic programming experience in Java or C. Table of Contents 5 About the Authors 9 About the Technical Reviewer 10 Introduction 11 Chapter 1: Getting Started 14 The Oracle Virtual Machine 15 Chapter 2: What Is a Database? 17 Referential Integrity 18 Null Values 18 Primary Keys, Foreign Keys, and Indexes 19 Joining Tables 19 Normalization 20 Structured Query Language (SQL) 20 Working with the Oracle Database 21 How to Open and Use SQL Developer 22 Chapter 3: Installing and Running Eclipse 23 Chapter 4: Bullhorn Site Overview 26 The Components of Bullhorn 26 What Does Each Page Look Like? 28 Editing a Profile 32 Chapter 5: What Is MVC? 34 The Model, View, Controller, and Service in Bullhorn 35 Chapter 6: Creating a Web Application 37 Chapter 7: The DAO/Repository 40 Implement Java Persistence (JPA) 43 The Persistence.xml File 45 The JPA Entities 47 Chapter 8: The Service Layer 52 Create a DbUtilities Class 52 Create the DbUser Class 53 Create the DbPost Class 60 Chapter 9: The Controller 65 What Is a Servlet? 65 Getting the Form Data into the Servlet 67 Sending the Data to the Next Page 67 How the Servlet Finds the Next Page 68 How to Set Values on Your Output Page 68 How the Log Out Button Works 69 The Login Servlet Code 69 The News Feed Servlet Code 72 The PostServ Servlet Code 75 The Profile Servlet Code 77 The AddUser Servlet Code 82 Chapter 10: The Presentation/View 85 Chapter 11: Designing Web Pages with HTML 86 Chapter 12: HTML5 Tags 88 Explanation of Common Tags 89 HTML Tables 92 A Basic HTML5 and JSP Document 93 JSP Standard Tag Library (JSTL) 94 What Can You Do with JSTL? 96 Prevent Cross-site Scripting Attacks 96 Loop Through a Collection 96 Set a Value 97 Test a Condition 97 Repeat Content a Fixed Number of Times 98 Test a Condition and Choose an Alternative 98 Determine If a String Is Null or Empty 99 Formatting Dates 99 How to Display Form Data 100 Create an HTML Login Form 100 Create a Page to Display the Output of Your Form 102 How to Allow the User to Navigate Between Web Pages 103 Reusing JSP Code 103 Customizing Your Errors 104 Chapter 13: The Stateless Nature of the Web 107 The Process of Passing Data 108 Chapter 14: Users and Sessions 110 Adding Objects to the Session 112 To Read a Value from the Session 113 Chapter 15: How to Create Database Tables for Bullhorn 114 Chapter 16: Make Web Pages Do Something Using JavaScript 116 Validate a Form Using JavaScript 117 Display Number of Characters in Text Box 119 Chapter 17: Cascading Style Sheets (CSS) 120 Span and Div Tags 121 Chapter 18: Making Pages Work on All Screen Sizes 124 Working with BootStrap 125 Chapter 19: Use Gravatar to Display User’s Avatars with Posts 127 Calculating an MD5 Hash with Java 128 Chapter 20: The Presentation/View 130 The Code for the Login Page 130 The Code for the Home Page 132 The Code for the News Feed Page 133 The Code for the Profile Page 135 The Code for the Add User Page 137 The Code for the Support Page 138 The Code for the Error Page 139 The Navbar Include File 139 The BootStrap Include File 142 The Bootstrap Style Pages 143 The Footer Include File 143 Index 144 Front Matter ....Pages i-xv Getting Started (Dave Wolf, A. J. Henley)....Pages 1-3 What Is a Database? (Dave Wolf, A. J. Henley)....Pages 5-10 Installing and Running Eclipse (Dave Wolf, A. J. Henley)....Pages 11-13 Bullhorn Site Overview (Dave Wolf, A. J. Henley)....Pages 15-22 What Is MVC? (Dave Wolf, A. J. Henley)....Pages 23-25 Creating a Web Application (Dave Wolf, A. J. Henley)....Pages 27-29 The DAO/Repository (Dave Wolf, A. J. Henley)....Pages 31-42 The Service Layer (Dave Wolf, A. J. Henley)....Pages 43-55 The Controller (Dave Wolf, A. J. Henley)....Pages 57-76 The Presentation/View (Dave Wolf, A. J. Henley)....Pages 77-77 Designing Web Pages with HTML (Dave Wolf, A. J. Henley)....Pages 79-80 HTML5 Tags (Dave Wolf, A. J. Henley)....Pages 81-99 The Stateless Nature of the Web (Dave Wolf, A. J. Henley)....Pages 101-103 Users and Sessions (Dave Wolf, A. J. Henley)....Pages 105-108 How to Create Database Tables for Bullhorn (Dave Wolf, A. J. Henley)....Pages 109-110 Make Web Pages Do Something Using JavaScript (Dave Wolf, A. J. Henley)....Pages 111-114 Cascading Style Sheets (CSS) (Dave Wolf, A. J. Henley)....Pages 115-118 Making Pages Work on All Screen Sizes (Dave Wolf, A. J. Henley)....Pages 119-121 Use Gravatar to Display User’s Avatars with Posts (Dave Wolf, A. J. Henley)....Pages 123-125 The Presentation/View (Dave Wolf, A. J. Henley)....Pages 127-140 Back Matter ....Pages 141-145 Build an online messaging app using Java Servlets, JSP, Expression Language, JSTL, JPQL, Sessions/Cookies, HTML/CSS/JavaScript, and the Bootstrap framework. This book explains Java EE, along with its associated technologies making it perfect for those with at least basic programming experience in Java or C. Java EE Web Application Primer teaches you how to develop complete web applications using Oracle as the database. By the end of the book you will have developed an online messaging app like Twitter. From there you can create other applications such as an online survey tool. You will: Build a Twitter-like web application called Bullhorn using Java, Oracle, and more Create web applications using Eclipse Design web pages with HTML forms, tables, and more Use SQL along with Java and Oracle for database accessibility Connect to a database using the Java Persistence APIs Create dynamic web pages with JavaScript, JSP, and the tag libraries Get web pages to stand out with Bootstrap, jQuery, and CSS