Professional Documents
Culture Documents
WT (UNIT-4)
WT (UNIT-4)
WT (UNIT-4)
< [body >
|< Ihtal>
Scanned with CamScannerOutput +
emo fon Templake Teak =x T=
Twinkle Tusinkle
litle stan
© Hello
Teh is equal to HIML and TAUA
Scanned with CamScanner@)
Jsp — Timplicit Objects :
‘The Tmplicit Objects ae the Jaua objects thot:
Ihe TSP conkainen maker available bs the
developers in each page and the developer can
call ners ctineckly evithout being explicitly
cleclaned
* Following table Usts out dhe nine Implécit
Objects at” ISP Suppomts —
© request | This is the MltpSewlet Request
object associated with the areqyro
© d1esporvse This is the AWpSewletRepone abject!
associated eith Ane sespormie to The
client
© ouk This is the Potinctalaiken object cased
fe send output t the client
© Session This is the HipSession object arrotia
Led eaith the srequest
eagplication | This is the SewletContert obj ete
asnotiaked with Ihe application context
° Contig This Ie the SewletConfi obj ec:
ameciaked will dhe page:
spege Contert | This encapsulaker ase of Sewer specifi
featrores like higher petfsrrance
Topwirikens
meas ‘Bis Ws simply a synonym for this, &
is used to ell the methods clefined
by he Granalated senvlet class
Scanned with CamScanner© Exception
The Exception abject aller dhe
exception data to be accessed by
desiernated Isp.
Scanned with CamScannerPages : oO
Using Beans an Tsp
A TaaBean is a Specially conskucked Tava
claw comitten in dhe Term and ceded actortirg
fo dhe TauaBeans APT specifications.
* Following are the nique characteristics
dhat distinguish a TJauaBean from othen
Tava classes —
e Tk provides a default, no-angament
censtructon
® Tk should be Setatigable and that ochich
can inmplement ‘the Serializable ineerkace
® Fk may have a sumber of properties
which can be mead om conitten.
e xk have a Aumben 3h . gehen" and
" Setten’ methods fpa the Ppropertics.
JariaBeans Properties +
A JavaBean property is a named athailate
dhat can be accessed by the wsen of the
object: The attribute can be of any Java
daka bype + ‘inclucting the clasnes that ge lefare|
* A TFauaBean property wiag be read,
wortke, mead only on conite only. TauaBean
Properties ane accemed Ahnough tee methods
in dhe JavaBeans implernentakion class —
Scanned with CamScanners-Ne
get Pacpentyname ¢ >
Fon example if property name 1s fpersktlame,
jour method name weuld be gekFiatNamec)
& riead cthak paroperty This method is
Called accedson.
set PaopertyName ©)
g
Qs
Fon example, ih properly name is fosthlare,
jour methed name oould be set FioukName O)
fo wotite thak property - This method 1s
called nuctaton.
* A read-only atlotibute will have only
a get Pnopenbynlame©) method, and a ewnite—
only attotibute evill have only a set Pacpery Name (
g
methed-
I! Example
public clas Skident Bean implements Senialigable
String Roo;
Sbirg Nlame :
Public void setRno ( Stig ano)
t
his Rno = mos
Scanned with CamScannerpublic vold get no ( fetag ) @
{
ack Rno;
4
public void sethlarne CString name)
q
his Name = name 5
5
Public void getName )
g
aekiad Warne ;
j
+ Thene ane Vania Scopes casing, eshich “the
bean can be used in Isp Page
) page Scope +
Te bean object gels disappeared a> A000
dine cucrenk page gees discanded. Me default
Scope fpr o bean WO jsp Prge Isa page scope
2) Recyuest Stope!
Me bean object semainr in existence ar Long
as the meanest object is present
8) Session Scope:
A session can be defined os a specie
poriod oh Aime ,
" oe
3
i>
| < [body >
|
|
|
|
Scanned with CamScannerTsP ©
Session Handling is
we use a request scope and by to access
the data over multiple pages, then same data
can be chanel by multiple pages: But sometimes
we need le use game data a, maltiple
Aequests FoA example in Alospitat management
austem , the dient infostma tion is, enbened
initicully only That patient may eenlerg 0
dhaough vortices bests 8 operations . TE is
then Shot necessary fox him cto enter he some
formation ouet again and in. Te same set
of information is used by uSsiows operations
Yn the hospital mnanagernent system: In such
session scope Is used
a case the
* HTTP is a request -mesponse p2ctocol
Rak means ehen user eaants to access some
toeb page, the web berowser makes nequeat to
sewer ‘and server arekcuins thet page oo
sresponse -
x Buk at she same dime HTTP is also
called as a stateless protocol That means
ashen browser sends a rrecyttest te the server,
Beer processes it afd sends the metponie
fy the browse and does not srememben
anyini about the mecyuest: So eshen borwuse}
sels “tee game sieayuest do the Seroen,
talces IE as o New prea een proce:
So, ie is areqpuirred dhak seiuen Should Eeep
brads oh the usen on mequek made by the
his prwoblern Anene ane thetee
sower
user To Solve
methods used -
Scanned with CamScannerbetroeen browsen and seweT, Uso an
Thus
| Use of Cookies
a Embedding hicklen fields tn an stmt Aisin,
3 Sending ORL string in mesporse body
* Fon sendi in fommetion +o and fre
ap is used: Mis TD is basi a Session-1b,
session- TD is Passed bekween the
browse and sower hile — pocesst the,
inypamnation - This method of keaping Grace of;
au cthe information lbebween senven and
browser wing Session- 2D Is called session
trode na
Scanned with CamScannerComectir
se bo database win JSP Ly)
(
“There axe 5 steps fa connect any java |
. . gd
application esith dhe database in java using
Wee» Mey are as follows *
& Registen the dotiver class
b Creabing connection
9 Creating statement
d) Executing qyuotiet
2 chosing connection
a) Reglsten the dativen class :
The fosNamet) method of class is used fo
jeken the doiven class. This method is used
bo chyncart cally load the dave class
Is :
nto:
public static void foaXame(Sbing classlame)
Ahrows ClascNot Found Exception
Example :
Class. fosiname Cc com: mays + Jd bc. Deaiven”);
8) Coreate the connection objec: :
‘The arbconnection() method ob DaivenM
class is used ke establish connection esith
dhe database .
i
Scanned with CamScannerSyntace :
public static Connection get Connection (Shing
wal, Shing nome , Shing passuoad )
Example +
Connection con = Dai Manage: get Connection
Cust, user, password );
6) Careate a Statiment Object:
Tre Cieake Statement ¢) method of Connection
inkothace Is used bo create skakement» The
object of skaternent is respontible te execute
quuenies with the chtabase »
4g nkat!
public Statement create Statement ©) Ahsrowt
SQLException
Example:
Statement stink = con, creake Statement) ;
4) Crete he quest?
the execute Query C) method of Skakernent
interhace is used fo execute queries to the
dokobase. This method rsebuant the object
of ResulkSet thak can be used to ae all
the mecords» of the table -
Scanned with CamScannerS
Syntax: (
public ReswhSet exetube Queny (Sbing sl)
thors SQLException
Exon ple :
ReselkSet ris = skmnk. executeQueny (" select -«
J
from esp")
e) close the, Connection object:
By chosing connection , object skakernenk and
Resulk set sill be closed autorsati cally. The
cloce 6) method ob Connection interface is
used to close the Connection
| Syntace :
public void closed) fhorows — SQLException
| Example:
con: close OC);
Scanned with CamScannerYou might also like