Java EE Web Application Primer: Building Bullhorn: A Messaging App with JSP, Servlets, JavaScript, Bootstrap and Oracle 1st Edition Dave Wolf - The ebook with all chapters is available with just one click
Java EE Web Application Primer: Building Bullhorn: A Messaging App with JSP, Servlets, JavaScript, Bootstrap and Oracle 1st Edition Dave Wolf - The ebook with all chapters is available with just one click
com
https://textbookfull.com/product/java-ee-web-application-
primer-building-bullhorn-a-messaging-app-with-jsp-servlets-
javascript-bootstrap-and-oracle-1st-edition-dave-wolf/
OR CLICK HERE
DOWLOAD EBOOK
https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-loucas/
textbookfull.com
https://textbookfull.com/product/murach-s-java-servlets-and-jsp-3rd-
edition-murach-training-reference-joel-murach-michael-urban/
textbookfull.com
https://textbookfull.com/product/java-ee-6-with-
glassfish-3-application-server-1st-edition-heffelfinger-david/
textbookfull.com
The Definitive Guide to JSF in Java EE 8: Building Web
Applications with JavaServer Faces Bauke Scholtz
https://textbookfull.com/product/the-definitive-guide-to-jsf-in-java-
ee-8-building-web-applications-with-javaserver-faces-bauke-scholtz/
textbookfull.com
https://textbookfull.com/product/building-web-and-mobile-arcgis-
server-applications-with-javascript-lewin/
textbookfull.com
https://textbookfull.com/product/beginning-ejb-in-java-ee-8-building-
applications-with-enterprise-javabeans-jonathan-wetherbee/
textbookfull.com
https://textbookfull.com/product/responsive-web-design-by-example-
embrace-responsive-design-with-html5-css3-javascript-jquery-and-
bootstrap-4-hussain/
textbookfull.com
https://textbookfull.com/product/beginning-jsp-jsf-and-tomcat-java-
web-development-expert-s-voice-in-java-2-new-edition-zambon-giulio/
textbookfull.com
Java EE Web
Application
Primer
Building Bullhorn: A Messaging
App with JSP, Servlets, JavaScript,
Bootstrap and Oracle
—
Dave Wolf
A.J. Henley
Java EE Web
Application Primer
Building Bullhorn: A Messaging
App with JSP, Servlets,
JavaScript, Bootstrap and
Oracle
Dave Wolf
A.J. Henley
Java EE Web Application Primer: Building Bullhorn: A Messaging App
with JSP, Servlets, JavaScript, Bootstrap and Oracle
v
Table of Contents
vi
Table of Contents
vii
Table of Contents
Index�������������������������������������������������������������������������������������������������141
viii
About the Authors
Dave Wolf is a certified Project Management
Professional (PMP) with over 20 years of
experience as a software developer, analyst,
and trainer. His latest projects include
collaboratively developing training materials
and programming bootcamps for Java and
Python.
ix
About the Technical Reviewer
Manuel Jordan Elera is an autodidactic
developer and researcher who enjoys learning
new technologies for his own experiments and
for creating new integrations.
Manuel won the 2010 Springy Award—
Community Champion and Spring Champion
2013. In his little free time, he reads the Bible
and composes music on his guitar. Manuel
is known online as dr_pompeii. He has
tech reviewed numerous books for Apress,
including Pro Spring Messaging (2017), Pro Spring, 4th Edition (2014),
Practical Spring LDAP (2013), Pro JPA 2, Second Edition (2013), and
Pro Spring Security (2013).
Read his 13 detailed tutorials about many Spring technologies or
contact him through his blog at http://www.manueljordanelera.
blogspot.com. You can also follow him on his Twitter account,
@dr_pompeii.
xi
Introduction
Are you a Java developer wondering how to create an Enterprise
application? Do you find the different components overwhelming or
confusing, not knowing how they go together? We’re here to help. What if
you could just get an example application working and use that knowledge
to continue your Java journey?
This book and the accompanying code will show you one way to
create a website. It’s not the only way. It may not be the best way for
every application. But it’s a way that will introduce you to the different
components of Java Enterprise application development. And it’s a good
way to get started.
In Java EE Web Application Primer, you’ll learn the basics of Java EE
application development. You’ll see how the parts connect. You will have
the Java code for a complete, working application.
The Software
Our students take our courses to learn how to program for large
companies. We have found these are the skills most requested by the
companies hiring our students. We choose to use Java 8, Oracle 12c, and
Eclipse for developing the application. Similarly, we choose to use JPA
(Java Persistence API) instead of Hibernate. We choose JSTL (Java Standard
Tag Library) over other available options. Again, these technologies teach
core skills without hiding all the implementation details from the student.
Our application is designed to teach. We provide the complete source code.
xiii
Introduction
You will learn much simply by reviewing and modifying the source code.
This book answers the questions you may have after working with the
source code, and the source code helps explain how the concepts in this
book have been implemented.
xiv
Introduction
If you’re ready to get started and develop your first Java Enterprise web
application, we thank you for choosing our book to begin your journey.
Know that you will face challenges and frustrations. You aren’t alone. We
have found that as our students worked through those, they learned more
about software development than we could ever teach in a book. You’re in
the right place. Wait no longer. It’s time to move on to Chapter 1!
xv
CHAPTER 1
Getting Started
VirtualBox allows you to create virtual computers within your physical
computer, enabling you to run multiple computers on one system. Setting
up VirtualBox requires very few steps. Once installed, you can then import
an existing virtual computer and begin work using that system.
Click and run the file to install VirtualBox just like with any other
software you’ve ever downloaded. If you are using Windows, double-click
the setup file and follow the prompts to install. If you are using a Mac, open
the DMG file that you downloaded and drag the VirtualBox file to your
Applications folder. During the installation, keep all of the options set to
their default.
Start the VirtualBox program. VirtualBox allows you to manage
your various virtual machines and easily create new ones. You can run
VirtualBox directly from the installation program, or you can start it from
the desktop icon.
Once you have the Oracle virtual machine file ready, select File ➤
Import Appliance in the menu bar. Click the Open Appliance button to
select the Oracle virtual machine file. Navigate to the file with the .ova
file extension. Selecting this file will open a dialog box in VirtualBox that
displays the settings. You can select the Import button from here. The next
window will show you the configuration of the current virtual appliance.
Once you click on Import, VirtualBox will copy the disk images and
create a virtual machine with the settings described in the dialog. You will
see the Oracle virtual machine in the VirtualBox Manager’s list of virtual
machines. The VirtualBox Manager is the first screen that opens when you
open VirtualBox. Select your machine, click Start, and give it time to load,
then you can work with that machine as if it were a separate computer.
2
Chapter 1 Getting Started
Note If you’re not using the Oracle virtual machine, you can
complete everything in this book using Windows.
You can download and install Oracle database version 12c for
Windows at http://www.oracle.com/technetwork/database/
enterprise-edition/downloads/database12c-win64-
download-2297732.html.
You will also need to install SQL Developer, which you can find at
http://www.oracle.com/technetwork/developer-tools/
sql-developer/downloads/index.html.
Finally, you will need to install Eclipse Oxygen from http://www.
eclipse.org/downloads.
3
CHAPTER 2
What Is a Database?
A database is a place to permanently store data for retrieval in a safe,
efficient way. A database allows us to create data and save it permanently.
It allows us to retrieve previously created data, update existing data, or
delete existing data.
A transaction groups SQL statements so that they are all applied to
the database. If one statement fails for some reason, all the statements
are undone from the database. Transactions ensure data integrity.
Transactions distinguish a database management system such as Oracle
from a file system.
The properties of a database transaction that ensure data validity are
atomicity, consistency, isolation, and durability.
The database stores data in sets, which are most commonly viewed as
tables. One row of a database table represents a record containing related
attributes, called fields. Fields are represented by the columns in a table.
Referential Integrity
Your database management system (DBMS) supports referential integrity.
The goal of referential integrity is to avoid having “orphaned” data.
Orphaned data can happen when you are deleting or updating the data
in your tables; for example, if you have a post in your database that does
not have a matching user. This shouldn’t happen and is often the result
of importing poorly formatted data or inadvertently deleting a user. A
database management system such as Oracle can enforce referential
integrity to prevent this by denying changes that will result in orphaned
data.
Null Values
Sometimes there is no value in a column of a row. In this case, the column
stores a NULL value. You can think of this as a flag to indicate the absence
of data. NULL is different from the numeric value zero or a string with a
length of zero characters. It is neither. It is nothing, because no value has
been stored in the column for this record. NULL, it turns out, is very useful.
You can search for a field in records that contain NULL and know that they
are the ones with no value in the field.
6
Chapter 2 What Is a Database?
Joining Tables
Relationships are a means to join data to different tables. This helps you
avoid redundancy in the tables. You can divide your data into different
tables—entering it only once—and then reference it from other tables by
establishing relationships.
7
Chapter 2 What Is a Database?
Normalization
In a normalized data structure, each table contains information about a
single entity and each piece of information is stored in exactly one place.
Normalization is the process of efficiently organizing data in a
database. This is done by organizing the columns (fields or attributes) and
tables of a relational database to minimize data redundancy.
The goals of the normalization process are to eliminate redundant data
and ensure data dependencies make sense.
8
Chapter 2 What Is a Database?
9
Chapter 2 What Is a Database?
10
CHAPTER 3
Installing and
Running Eclipse
Your virtual machine contains all the software you need to create
Bullhorn—the Oracle Database 12c, SQL Developer, and Java 1.8—but it
doesn’t contain the Eclipse IDE. You will need to download and install that
yourself. Fortunately, the installation process is very easy.
To install Eclipse on the virtual machine, you will need to open Firefox and
download the Eclipse archive. Then, you will need to extract the files from the
archive. Next, you will need to run the setup program that is included in the
archive files. Finally, open Eclipse.
1. From the virtual machine, open the Firefox web browser. You
can get to Firefox by clicking on the Applications menu and
selecting the icon for Firefox Web Browser.
5. Select the option to open with the Archive Manager when this
window is displayed. The Archive Manager is the program that
will extract your files.
11. Accept the default workspace. This is where your project files
will be kept.
12
Chapter 3 Installing and Running Eclipse
3. Notice that the port numbers are shown in the table on the
right. Click to edit; for example:
4. Once you change the port number for HTTP from 8080 to 9000,
you should press Ctrl + S to save the change and restart the
server.
Your application should now run without conflict. If you do get a conflict, then
you’ve chosen another used port. Repeat the process with a different port
number. It’s best to select a port within the range of 1025 to 65535. You can
research “Well-known port numbers” to find many articles explaining the
reasoning here.
13
CHAPTER 4
JPA (data
access)
Classes
Bullhorn Overview Diagram
Session - visible to all servlets and JSPs
Session times out 20 minutes after last accessed
Database
User object in session is available to all servlets and JSPs Posts Table
Users Table
Newsfeed
Login Servlet Home Servlet
Servlet
Tip To keep your HTML from getting too complicated, use CSS
(Cascading Style Sheets) and JavaScript to control the presentation of
your content and let HTML control the layout.
The Bullhorn application contains web pages for login, home, news
feed, and user profile. The user starts at the login page. Once the user
clicks the Login button, the request (data from the login form) will be sent
to the login servlet.
16
Chapter 4 Bullhorn Site Overview
The login servlet will validate the user against the database. A
valid user will be stored in the session, which is the website’s way of
remembering data between page views. Invalid users will not get past the
login page until they enter a correct username and password combination.
We will create other objects (classes) to validate data or support the
classes and pages shown in the diagram.
Figure 4-2. The login page contains text boxes for email and
password and a button to sign in to the application
17
Chapter 4 Bullhorn Site Overview
The home page will allow each user to create a new post. Each post is
limited to 141 characters, so the home page enforces this restriction (see
Figure 4-3). Once the user is logged in, all pages contain a navigation bar at
the top that allows the user to navigate to different pages, view or edit their
profile, and search for posts containing a specific word.
Figure 4-3. The home page contains a form to submit a post to the
database. The form contains a text box and buttons to either submit
the post or clear the form.
Each page contains the same navigation bar, which allows the user
to move around the application. The navigation bar contains the logo,
links for the home page and the news feed page, and a search box. It also
displays the name of the logged-in user. The user can also select from
various user options, which is implemented as a drop-down list. These
include logging out, viewing or editing profile, and submitting feedback.
See Figure 4-4.
18
Exploring the Variety of Random
Documents with Different Content
Kävelin kuin juovuksissa, sydäntäni särki, en tietänyt mihin
menisin. Vieraskotiin ei tehnyt mieleni yöpyä, siellä oli melua ja
juoppoutta. Tulin johonkin kaupungin ulkopuolelle, siellä oli pieniä
taloja, jotka keltaisilla ikkunoillaan katselivat pellolle päin; tuuli
leikitteli lumen kanssa, peitteli taloja ja vihelteli niiden ympärillä.
Janotti, olisin juonut vaikka itseni juovuksiin, mutta en ihmisten
seurassa. Olin kaikille vieras ja kaikkien edessä syypää.
— Mikä nimesi?
Hän nauroi.
— Juhlapäivinäkö?
Kyselin nuoremmalta:
— Virkkaamme pitsejä.
Vaan minä en tiedä mitä sanoa, ja miten lähteä pois niiden luota,
pääni oli ihan tyhjä! Istun ja vaikenen. Tuuli naputtelee ikkunassa,
samovari sihisee, vaan Tatjana puhuu aivan kuin hän tahtoisi
ärsyttää minua.
— Mitäs suret?
— Vaimoni kuoli.
— Koska?
— Ei ole ketään.
— Vaan tovereita?
— Ei tovereitakaan ole.
— Minä en tiedä.
— Mitä esipappia?
Hän pyysi minua juomaan likööriä tahi teetä, kysyi, tokko minä
tahtoisin syödä. Minun silmiini tuli kyyneleitä hänen totisen
hellyytensä takia, sydämeni iloitsi kuin aamulintunen
kevätauringosta.
— Käyttekö te kirkossa?
Minä tunsin että hänessä silloin oli jotain hyvää, sydämellistä, vaan
minä en jaksanut käsittää.
Minä sanoin:
— Mahdotonta on elää kun ei näe Jumalaa!
— Aika on nousta.
Jonkun ajan päästä olin minä äiti Fevronian kammiossa. Hän oli
pieni akka, silmissään koko ajan kyyneleet, ja ryppysillä kasvoillaan
vapisi lakkaamatta hyvä hymy. Hän puhuu hiljaa, melkein
kuiskaamalla ja laulavalla nuotilla.
Minä rukoilin:
Hän myrisi:
— No?
Hän sanoi:
Hänen suunsa oli iso, hampaansa olivat isot, kädet pitkät ja hän
heilutti niitä sangen epäystävällisesti.
Miha suuttui:
Minua nauratti.
— Nopeammin tee!
— En, en koskaan.
— Valehtelija, haureilija!
— Herra Jumala, vie pois naisen halu, rukoilen sinua! Vie pois
naisen halu! Vapauta.
Minä tahdoin puhua tuon kauniin munkin kanssa, vaan näin hänet
harvoin ja ohimennen — jossain kaukana lensivät ohi hänen ylpeät
kasvonsa ja minun ikäväni kulki hänen perässään näkymättömänä
varjona.
— Uskonnosta, näettekös.
Minä huomasin myös, että luostarilla oli aika suuri liike: se kävi
metsäkauppaa, vuokrasi maita talonpojille ja kalastamisoikeutta
järvellä, sillä oli mylly, iso yrtti- ja hedelmätarha; se möi omenia,
marjoja ja kaalia. Tallissa oli kahdeksantoista hevosta, veljiä oli
enemmän kuin viisikymmentä ja kaikki olivat vahvoja, työskenteleviä
miehiä, vanhuksia oli vähän, niitä tuskin riitti paraadin ja
pyhiinvaeltajien varalta. Munkit joivat viinaa ja harrastivat
innokkaasti naisia; nuoremmat juoksentelivat öisin kylässä, vaan
vanhempien luona kävivät naiset kammioissa, muka lattiaa
pesemässä; tietysti käytettiin myös naisia, jotka kävivät
rukousmatkoilla. Vaan tämä kaikki ei ollut minun asiani, enkä minä
heitä voinut tuomita, en nähnyt siinä minkäänlaista syntiä, vaan
valhe minua iletti. Luostariveljiä oli paljon, vaan palvelukset olivat
niin raskaita, että harvat pysyivät paikallaan, muut karkasivat. Minun
aikanani, niiden kahden vuoden kuluessa kun luostarissa olin, karkasi
siitä yksitoista ihmistä; elivät pari kuukautta — ja auta, Herra,
jalkojani! Oli raskasta!
— Olin.
— Juttelitteko?
— En.
— Kuinka niin?
Kysyinpä Grishalta:
Hän kiihtyi yhä enemmän; hän oli puhdas ja hellä ihminen, minä
rakastin häntä.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com