You are on page 1of 224

J2EE

Servlets &
JSP


Chapter:
1JAVA
AND THE
J2EE
PLATFOR
M
Topics
Discussed

Introductio
n

Enterprise
Today

System
Architectur
e2-Tier
Architectur
e3-Tier
Architectur
en-Tier
Architectur
eEnterprise
Architectur
e

Is Java the
Answer?Pl
atIorm
Independen
ceReusabili
tyModularit
y

The J2EE
PlatIorm

J2EE
Architectur
e
Containers
1.1
Introduction
Java, as a
programmi
ng
language is
still young.
However,
the
evolution
oI
JavaIrom a
means oI
developing
applets Ior
running in
browsers,
to a
programmi
ngmodel
capable oI
driving
today`s`
enterprise
application
s has been
remarkable
.Java has
been
around Ior
only Iive
years, yet it
has
attracted a
very high
level
oI interest
in the
technical
and
business
communitie
s, Iuelling a
considerabl
e rangeoI
application
s.From its
inception,
Java has
triggered
new
programmi
ng models
and
technologie
sin
diIIerent
domains
ranging
Irom
devices, to
telephony
application
s, to
theenterpri
se. At the
same time,
Java has
acted as a
catalyst in
making
certaintech
nology
domains
take more
robust and
secure
shapes.
Java`s
enterprisec
omputing
platIorm,
a.k.a. the
Java 2
PlatIorm,
Enterprise
Edition
(J2EE)
isone such
domain.Th
ere were
times in
the history
oI Java,
when
debates on
whether
Java is
aprogram
ming
language
or a
platIorm
used to
surIace in
the media
as well
astechnical
circles.
However,
J2EE is
one oI the
most
successIul
attempts by
Sunand its
associates
at making
Java
credible as
a
platIorm
Ior
enterprise
computing.
But what is
J2EE? Why
is it
relevant?
Why
should you
choose this
technology
Iorbuilding
enterprise-
level
application
Irom
client-
server to
Internet to
mobile?Thi
s chapter
gives one
perspective,
and assists
you in
answering
these
6uestions.
We hope
that the rest
oI this book
will help
you to
successIull
y build and
managesuc
h
application
s.In this
introductor
y chapter,
we`ll Iocus
on

The J2EE
technical
architecture
1


J2EE
Servlets &
JSP



What
makes
J2EE
credible as
a platIorm

What are
the
challenges
it addresses

What
technologie
s constitute
the J2EE
platIormFir
st however,
let us start
with the
challenges
oI
developing
application
s Ior
theenterpris
e today.
1.2 The
Enterprise
Today
With the
advent oI
the
Internet,
many
businesses
realized
that a
whole
newmarket
had opened
up to be
exploited,
however,
we doubt iI
many had
realizedwh
at a radical
eIIect it
would have
on the
economy.
Through
the Internet
and
therecent
growth oI
e-
commerce,
an
organizatio
n`s
inIormatio
n assets
have
nowbecom
e more
valuable.
This shiIt
to an
inIormatio
n economy
is Iorcing
manybusin
esses to
rethink
even their
most basic
business
practices.
In order
tomaintain
a
competitive
edge, the
adoption oI
new
technologie
s has
become a
keyIactor
in a
company`s
ability to
best
exploit its
inIormatio
n assets.
Moreimpo
rtantly,
adapting
these new
technologi
es to work
in tandem
with
theexisting
, legacy
systems
has become
one oI the
Ioremost
re6uiremen
ts oI
theenterpris
e.One
place these
shiIts in
business
practices
have been
Ielt most
keenly is at
theapplicati
on
developme
nt level.
The
Iunding and
the time
allocated to
application
developme
nt have
been
shrinking,
while
demands
Ior
complexity
have
increased.A
lthough the
emphasis
on
inIormation
is a small
hurdle Ior
developers,
the
wholerevol
ution is
being
driven by
the rapidly
changing
technologic
al and
economicla
ndscape,
which has
created
some new
challenges
Ior today`s
enterprisea
pplication
developers:

Responsive
ness
Although
timeliness
has always
been
important,
the high-
placed,
Iast-
changing
inIormatio
n-driven
economy
means that
responding
6uickly
tonew
directions
and
inIormation
is critical in
establishing
and
maintaining
acompetitiv
e edge.

Programmin
g
Productivity
Direct
adoption oI
new
technologie
s is
insuIIicient
unless they
are
properlyutil
ized to
their Iull
potential
and
appropriat
ely
integrated
with
otherrelev
ant
technologi
es. Thus,
the ability
to develop
and then
deployappl
ications as
eIIectively
and as
6uickly as
possible is
also
important.
Achieving
this can be
complicate
d by the
sheer
variety oI
technologie
s
andstandar
ds that
have been
developed
over the
years,
re6uiring
highlydeve
loped skill
sets, the
ac6uiring
oI which
and
keeping up
with which
is
aproblem
in itselI.
Moreover,
the rapid
pace oI
change in
+standards`
themselve
s poses
signiIicant
challenges
to ensuring
eIIicient
meshing
oI technolo
gies.

Reliability
and
Availability
In today`s
Internet
economy
downtime
can be Iatal
to the
success oI
abusiness.
The ability
to get your
web-based
operations
up and
running,an
d to keep
them
running, is
critical to
success. As
iI that
wasn`t`
enough,you
must also
be able to
guarantee
the
reliability
oI your
businesstra
nsactions
so that they
will be
processed
completely
and
accurately.
2


J2EE
Servlets &
JSP



Security
The
Internet has
not only
exponential
ly increased
the number
oI
potentialus
ers but also
the value
oI a
company`s
inIormatio
n, thus the
security
oI that
inIormatio
n has
become oI
prime
concern.
What`s
more
astechnolo
gies
become
more
advanced,
application
s more
sophisticate
d,
andenterpri
ses more
complex,
the ability
to
implement
an
eIIective
securitymo
del become
increasingl
y diIIicult.

Scalability
The ability
Ior the
application
to grow to
meet new
demand
both in
itsoperation
and user
base is
important
when an
application`
s potential
userbase
may be
millions oI
individual
users
through the
Internet.
To
scaleeIIecti
vely
re6uires
not only
the ability
to handle a
large
increase in
thenumber
oI clients
but also
eIIective
use oI
system
resources.

Integration
Although
inIormatio
n has
grown to
be a key
business
asset, much
oI
thisinIorma
tion exists
as data in
old and
outdated
inIormatio
n systems.
Inorder to
maximize
the
useIulness
oI this
inIormation
,
application
s need tobe
able to
integrate
with the
existing
inIormation
system
not
necessarya
n easy task
as current
technologie
s have
oIten
advanced
Iar ahead
oI some oI
these
legacy
systems.
The ability
to
combine
old and
newtechnol
ogies is key
to the
success oI
developing
Ior today`s
enterprises.
None oI
these
problem
domains is
especially
new to the
enterprise
developer!
Butsolving
these
problems in
a
comprehen
sive and
economical
manner is
still
crucial.You
may be
aware that
there have
been
several
technologie
s to address
one
ormore oI
the above
demands.
However,
what has
been
missing is
acomprehe
nsive
platIorm
with a rich
inIrastructu
re and
numerous
architectur
alpossibiliti
es that also
promotes a
rapid
developme
nt
environmen
t.
1.3 System
Architecture
When
discussing
enterprise
application
developme
nt, it is
appropriate
to
introduceth
e concept
oI
n-tier
architecture.
Typical
client/serve
r systems
are based
onthe 2-
tiered
architectur
e, whereby
there is a
clear
separation
between
the dataand
the
presentatio
n/business
logic.
These are
generally
data
driven,
with
theapplicati
on existing
entirely on
the client
machine
while the
database
server
isdeployed
somewhere
in the
organizatio
n. While
this
approach
allows us to
sharedata
across the
enterprise,
it does have
many
drawbacks.
1.3.1 2-Tier
Architecture
In a
traditional
2-tiered
application
, the
processing
load is
given to
the client
PCwhile
the server
simply acts
as a traIIic
controller
between the
application
and
thedata. As
a result,
not only
does the
application
perIormanc
e suIIer
due to
thelimited
resources
oI the PC,
but the
network
traIIic
tends to
increase as
well.When
the entire
application
is
processed
on a PC,
the
application
is Iorced
tomake
multiple
re6uests
Ior data
beIore
even
presenting
anything to
the
user.These
multiple
database
re6uests
can heavily
tax the
network.
3


J2EE
Servlets &
JSP


Another
problem,
with a 2-
tiered
approach
is that oI
maintenan
ce. Even
thesmallest
oI changes
to an
application
might
involve a
complete
rollout to
theentire
user base.
Even iI it`s
possible to
automate
the process,
you are still
Iacedwith
updating
every
single
client
installation
. What`s
more, some
users may
notbe
ready Ior a
Iull rollout
and ignore
the
changes
while
another
group
insists
onmaking
the
changes
immediatel
y. This can
result in
diIIerent
client
installation
using
diIIerent
versions oI
the
application.
1.3.2 3-Tier
Architecture
To address
these
issues, the
soItware
community
developed
the notion
oI a 3-
tierarchitec
ture. An
application
is broken
up into
three
separate
logical
layers,
eachwith a
well-
deIined
set oI
interIaces.
The Iirst
tier is
reIerred to
as the
presentation
layer
and
typically
consists oI
a graphical
user
interIace oI
somekind.
The middle
tier, or
business
layer,
consists oI
the
application
or
businesslog
ic and the
third tier
the
data layer
contains
the data
that is
needed Ior
theapplicati
on.The
middle tier
(applicatio
n logic) is
basically
the code
that the
calls
upon(throu
gh the
presentatio
n layer) to
retrieve the
desired
data. The
presentatio
nlayer
then
receives
the data
and
Iormats it
Ior
display.
The
separation
oI applicati
on logic
Irom the
user
interIace
adds
enormous
Ilexibility
to the
design
oI the
application
. Multiple
user
interIaces
can be built
and
deployed
without
everchangi
ng the
application
logic,
provided
the
application
logic
presents a
clearlydeIi
ned
interIace to
the
presentatio
n layer.The
third tier
contains
the data
that is
needed Ior
the
application
. This data
canconsist
oI any
source oI
inIormatio
n,
including
an
enterprise
database
such
asOracle
or Sybase,
a set oI
XML
documents
(data that
has been
stored
indocument
s
conIormant
to the XML
speciIicatio
n), or even
a directory
service
likean
LDAP
server. In
addition to
the
traditional
relational
database
storageme
chanism,
there are
many
diIIerent
sources oI
enterprise
data that
yourapplica
tions can
access.
4
DBApplic
ation

You might also like