0% found this document useful (0 votes)
29 views3 pages

Prajwal Jadhav - Webtechassign2

This document discusses the servlet technology lifecycle in 3 stages: 1. Initialization (init) method - The servlet is loaded into memory by the web server when it is first requested. Any initialization can occur here. 2. Service (service) method - This method handles the HTTP request and generates the response. It can invoke other methods to obtain runtime data and generate the response. 3. Destruction (destroy) method - The servlet is unloaded from memory by the web server. Any cleanup can occur here before removal. The full code for a simple "Hello World" servlet is provided as an example.

Uploaded by

Prajwal Jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Prajwal Jadhav - Webtechassign2

This document discusses the servlet technology lifecycle in 3 stages: 1. Initialization (init) method - The servlet is loaded into memory by the web server when it is first requested. Any initialization can occur here. 2. Service (service) method - This method handles the HTTP request and generates the response. It can invoke other methods to obtain runtime data and generate the response. 3. Destruction (destroy) method - The servlet is unloaded from memory by the web server. Any cleanup can occur here before removal. The full code for a simple "Hello World" servlet is provided as an example.

Uploaded by

Prajwal Jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

web Techno log y4

Assiqnmen 2

cyle o sevlel
what sseuvlet 9 Cxplaun
detail Wrile a pmgram locuisplayH Heuo Sng
Jorld " S ng
Servlet

SeHvlet axe basicaAlu (hepnoqr a m Ahat Hun


SeLve Thete a pro0qram hal a heguested by
he
the XHTMLdocuments and arsdusplaysed n
brouasu_window as a Hspons.e Io he ML9uest.
Seunletue cyele-
ASeHMt_ufeuee can_he _defuned a s t
nkire pmes omlt_olatuon_he _desuch nb

(i) init ) mitnod


i Servicemethod
deshos method
The clieni eners h e UR n the oebbmwst f_
make a reques t
The brouosergeneraH the HTP equestsen ds
L o h e Aweb_Server
WebServermaps MLSrequest to the comesponcung
Servle.
tininit Met hocd method
which_means

KeSint O
m e server
NNO o h e first
is 10aded jn t n e m e m o n
eriet
the
ime - arabnltis al
JHzaiu
hu metmod u wi sey
usin9
e sewyet in 0rde
o conHq
pased

)Service ()method
c a n i n y o ke
) method
fheSeYyiLe
SeHvi provideol
hen Yead_tme data
The seYvles
help Oh StYvice D
by he HIIP request with he
method.
Deshmy O _Menpd
+he Servet mm
final SLYVA unieads
h_desbOy) metha
memo _usinq

Prmaram

mpartjaYain
import jayax ServletNttp"

publiclass servlet Dem o exends HTTPservleB


PLLbiivojd_olo het_HApSerVletResponS e rquest,
Htpservlet Response resp onse_
msSeryletExce pHon, JotxLepHons
rEspons set comxnt ype t"text hm
print nfr_pw : response.qtwner ,
p pnnt <htm)")s
5erviet Hello
tn Knead) < t t l e )
pw. pIMA
Orlc IAite>/nead" J
P w r e l n ("<bocdy>")

pw pmn im h ) Hello norld / h > " ) P


(<bodyntm1>),
p pn ntln

Web x m i
1So- 88S-"9P>
xm version= :0" entoding
<I= DOCTYP
ln,/1DTb
nicrnsofisyskms,ln
RBLI / Sun
Appli catm_2 3 /16U1
web
/dtc/uweb-aupp- 2 - 3 dtd "2-->.
t p1java Sun:com

welo- app
Sservlet
servle - narne>Helo </servlet-name

servet class > g ervlet - O emo / s e r v i e - dass>


(serules )

Kservle map ping>_


servlet-ames Helo /Strvletman{
urlepatern>/seYv ema K/Ur-padern
1serylet - mappinq
NRb a p p

You might also like