Java Web Development with NetBeans IDE

nutmegactΛογισμικό & κατασκευή λογ/κού

10 Νοε 2012 (πριν από 4 χρόνια και 7 μήνες)

233 εμφανίσεις

Java Web Development with


NetBeans IDE

--
Kai Qian

Chapter 9



Case Study

Objectives



Introduction to Multi
-
tier Java Enterprise
Applications.


A Comprehensive Java Enterprise Application
Example.


Building and Deployment of Java Enterprise
Application


Introduction


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
.


T
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
order.


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.


Architecture

Overview


The MVC pattern will fit our project in the following
ways:


Model:


JPA Entities representing real
-
world objects and concepts.


Controller:


Java Servlets will handle incoming requests and decide the
flow of the application.


Java session beans will implement the application's business
logic.


View:


JSP pages will present a web interface for the user, gathering
input and displaying output.


Architecture Overview
, contd.

Enterprise Tier


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.


Session Beans


The session beans will implement the
application's logic, making up part of the
Controller in our MVC architecture.

Web Tier


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.

Servlets


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


an EJB
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
, contd.


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.

Chapter 9




The End