Anda di halaman 1dari 19

Web App||cat|on Deve|opment

Web AppllcaLlon
- A web application is a seivei-siue application that contains
Web components (Seivlets anu }SP pages), BTNLXNL
uocuments, anu othei iesouices in a uiiectoiy stiuctuie oi
aichiveu foimat known as a Web Aichive (WAR) file
- A web application is accesseu ovei a netwoik, such as the
inteinet oi intianet, using a web biowsei
- Web applications peifoims vaiious opeiations such as
accepting input uata anu uynamically geneiating one oi
moie uocuments as iesponses
- The iesponse web uocuments aie geneiateu anu uisplayeu
in stanuaiu foimats such as BTNL
Web ComponenLs
- In }ava EE platfoim, web components pioviue uynamic
capabilities foi a web seivei. Web components can be }ava
Seivlets oi }ava Seivei Pages(}SP), }ava Seivei Faces(}SF)
- Seivlets aie }ava classes that uynamically piocess iequests
anu geneiate the uesiieu iesponses
- }SP pages aie text-baseu uocuments that aie executeu as
seivlets, pioviue an appioach foi cieating uynamic web
pages
- Web components piocess iequests anu peifoim othei
iequiieu opeiations by help of a iuntime platfoim known
as a web containei
eploymenL escrlpLor
- Ceitain aspects of web applications can be configuieu when
the application is ueployeu on the web containei
- This configuiation infoimation is maintaineu in an XNL file,
calleu Web Application Beployment Besciiptoi
- Foi web applications, the ueployment uesciiptoi must be
calleu web.xml anu must iesiue in the WEBINF uiiectoiy
in the web application ioot.
- Foi }ava EE applications, the ueployment uesciiptoi must
be nameu application.xml anu must be placeu uiiectly in
the NETA-INF uiiectoiy at the top level of the application
.eai file.
@@9 9roLocol
- BTTP is a communication piotocol useu to tiansfei
infoimation on the Inteinet. It is a stateless anu
application-level piotocol.
- As an application level piotocol, BTTP also uefines the
type of iequest that clients can senu to seiveis anu the
type of iesponses that seivei can sent to clients
- Each iequest has a 0RL, which is a stiing that iuentifies a
we b component oi a static object e.g. BTNL page oi
Image file
- Theiefoi to biowse a 0RL anu communicate ovei a
netwoik, java Clients use BTTP
@@9 messages
- Each message, whethei a iequest oi a iesponse,
has thiee paits:
. The iequest oi the iesponse line
. A heauei section
. The bouy of the message
- The piocess of senuing a iequest anu ieceiving a
iesponse fiom the seivei is teimeu as BTTP
tiansaction
@@9 8equesL
GET /index.html HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0
Accept: text/html, */*
Accept-Language: en-us
Accept-Charset: ISO-8859-1,utf-8
Connection: keep-alive
-,330
GET /index.html HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0
Accept: text/html, */*
Accept-Language: en-us
Accept-Charset: ISO-8859-1,utf-8
Connection: keep-alive
-,330
URL Protocol Version Method
Headers
Body
(optional)
@@9 8esponse
HTTP/1.1 200 OK
Date: Thu, 24 Jul 2008 17:36:27 GMT
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=UTF-8
Content-Length: 1846
-,330
html>
...
/html>
HTTP/1.1 200 OK
Date: Thu, 24 Jul 2008 17:36:27 GMT
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=UTF-8
Content-Length: 1846
-,330
html>
...
/html>
$tatus $tatus Message Version
Headers
Body
WhaL Lhe cllenL does parL l
- The client senus a message to the seivei at a
paiticulai poit (8 is the uefault)
- The fiist pait of the message is the iequest line,
containing:
- A methou (BTTP commanu) such as CET oi PDST
- A uocument auuiess, anu
- An BTTP veision numbei
- Example:
- CET /Index.html HTTP/1.0
@@9 meLhods
- CET: Retiieves the iesouice iuentifieu by the iequest 0RL
- PDST: Senus laige amount of complex uata to the seivei
- HEA0: Like CET, but ask that only a heauei be ietuineu
- PUT: Request to stoie a iesouice at the 0RI
- 0ELETE: Request iemoval of uata at the 0RI
- DPTDNS: Request infoimation about communications
options on the seivei
- TFACE: Request that the iesouice be ietuineu as ieceiveu
(useu foi uebugging)
lfferences beLween CL@ and 9@
Parameter CET PUST
Transmission of
request parameters
As a queiy stiing appenueu to
the iequest 0RL
Within the bouy of the iequest
size Limiteu to a max. of chai.
in the 0RL (except the actual
path)
- Not limiteu by the size of the
0RL foi submitting namevalue
paiis.
- These paiis aie tiansfeiieu in
the heauei anu not in 0RL
Purpose 0seu only foi ietiieving uata 0seu foi ietiieving as well as
saving oi upuating uata,
oiueiing a piouuct oi senuing
e-mail
cacbing A uET iequest is often
cacheable
A P0ST iequest can haiuly be
cacheable
Type of purpose 0seu to access static
iecouises e.g. BTNL uoc. Anu
images
0seu to tiansmit a laige
amount of infoimation oi
iequest uepenuent infoimation

WhaL Lhe cllenL does parL ll


- The seconu pait of a iequest is optional heauei
infoimation, such as:
- What the client softwaie is
- What foimats it can accept
- All infoimation is in the foim Name: 7alue
- Example:
UserAgent: |ozIlla/2.02Cold (WInNT; )
Accept: Image/gIf, Image/jpeg, */*
- A Tlonk line enus the heauei
WhaL Lhe cllenL does parL lll
- The thiiu pait of a iequest (aftei the blank line) is the
entity-bouy, which contains optional uata
- The entity-bouy pait is useu mostly by PDST iequests
- The entity-bouy pait is always empty foi a CET iequest
WhaL Lhe server does parL l
- The seivei iesponse is also in thiee paits
- The fiist pait is the status line, which tells:
- The BTTP veision
- A status coue
- A shoit uesciiption of what the status coue means
- Example: HTTP/1.1 404 Not Found
- Status coues aie in gioups:
100199 Infoimational
200299 The iequest was successful
J00J99 The iequest was ieuiiecteu
400499 The iequest faileu
500599 A seivei eiioi occuiieu
Common sLaLus codes
W 200 DK
- Eveiything woikeu, heie's the uata
W J01 |oved Permanently
- 0RI was moveu, but heie's the new auuiess foi youi iecoius
W J02 |oved temporarIly
- 0RL tempoiaiily out of seivice, keep the olu one but use this one foi now
W 400 8ad Fequest
- Theie is a syntax eiioi in youi iequest
W 40J ForbIdden
- You can't uo this, anu we won't tell you why
W 404 Not Found
- No such uocument
W 408 Fequest TImeout, 504 Cateway TImeout
- Request took too long to fulfill foi some ieason
WhaL Lhe server does parL ll
- The seconu pait of the iesponse is heauei infoimation,
enueu by a blank line
- Example:
W ContentLength: 25J2
ConnectIon: Close
Server: CWS/2.0
0ate: Sun, 01 0ec 2002 21:24:50 C|T
ContentType: text/html
Cachecontrol: prIvate
SetCookIe:
PFEF=0=05J02a9J09Jec661:T|=10J8777890:L|=10J8777890:S=
yNWNjraftUz299FH; expIres=Sun, 17Jan20J8 19:14:07 C|T;
path=/; domaIn=.google.com
3365
6535
WhaL Lhe server does parL lll
- The thiiu pait of a seivei iesponse is the entity bouy
- This is often an BTNL page
- But it can also be a jpeg, a gif, plain text, etc.--anything the
biowsei (oi othei client) is piepaieu to accept
Web AppllcaLlon evelopmenL eploymenL
sLeps
. Bevelop anu Compile the web component (Seivlet oi }SP)
coue anu Belpei classes iefeienceu by the components
. Bevelop any static iesouices (e.g. Images oi BTNL pages)
. Bevelop the ueployment uesciiptoi (web.xml)
. Builu the Web application (*.wai file oi ueployment-ieauy
uiiectoiy)
. Beploy the web application into a web containei
. Access a 0RL that iefeiences the Web application
Web Module LrucLure

Anda mungkin juga menyukai