Java Web Development with
Introduction to Multi
tier Java Enterprise
A Comprehensive Java Enterprise Application
Building and Deployment of Java Enterprise
Let us consider the following scenario for the project: A book distributor
specializing in rare and hard to find books has hired us to create a website.
The client wants a site that will allow bookstore owners to register, log in,
browse the inventory of books, and place orders
he application must provide a way for a registered bookstore owner to
view his previous orders.
The shopping cart should allow a user to add books to the shopping cart,
saving all of the selections made until the user is ready to complete the
The bookstores should be able to include their distributor's inventory on
their web pages if they want to, allowing the end customer to purchase a
book online without knowing that it comes from the distributor.
The MVC pattern will fit our project in the following
JPA Entities representing real
world objects and concepts.
Java Servlets will handle incoming requests and decide the
flow of the application.
Java session beans will implement the application's business
JSP pages will present a web interface for the user, gathering
input and displaying output.
Our Enterprise Tier is made up of two
separate but related components.
We have session beans that implement the
logic for the application and the JPA entities
that make up the data model.
The session beans will implement the
application's logic, making up part of the
Controller in our MVC architecture.
The web tier makes up the View in our MVC
architecture, but also crosses over into the Controller
portion as well.
The Servlets act as controllers by accepting and
validating input, calling the appropriate session bean
methods, and handing off the results of the
processing to the View component (the JSP pages).
The distinction between View and Controller in the
web tier falls along the lines of separation between
Servlet and JSP.
The main purpose of the Servlets in our application is to
accept, validate, and parse the input from the user's web
browser, call the appropriate session bean methods, and
decide what the next step is
The Servlets in our application should never output HTML
directly to the client because that would cross the line
between Controller and View and would also cause us to have
to use all sorts of strange looking escape sequences for
outputting double quotes which, aside from looking hideous,
are hard to type.
Building and Deploying
NetBeans organizes the Enterprise Application
project into three separate projects
project containing enterprise components, a
web project containing web components, and
an Enterprise project that depends on the
other two and ties them together
To make things even more convenient,
NetBeans will also allow us to build and
deploy to the GlassFish application server
Building and Deploying
To deploy the application to a production
server will require the uploading the
Enterprise Archive (EAR) file to the application
server through the management console.
The EAR file is a special type of ZIP file that
contains a Java Archive (JAR) file containing
the EJB project components and the Web
Archive (WAR) file containing the web
components of the Enterprise project.