FOR PRIVATE CIRCULATION
ONLY.RE-DESIGNED FOR USIT
B.Tech STUDENTS.
Agenda
+ Why we need JSP
+ How JSP works
+ Benefits of JSP
Setting up your environment for JSP
+ A'simple example
The Need for JSP
+ With servlets, itis easy to
= Read foun data
—Remenber data between request:
~ Get fr, hagh-pavng jobs
+ But, it sure is apain to
= Use those pinnate to generate HTML
= Maintain hat HTML
The JSP Framework
+ Idea:
= Use rogue HTML for mest of
TNisk Svat code wth speeal
iste
_ ee unaraease arena
“a
ereeeh request}
eae (19 Ho
aoe es prune)
~ poor Catenin >
Real ores
Benefits of JSP
Although JSP technically can't do anything
serviets can't do, JSP makes it easier to:
= Wiite HTML
= Reed and nisin the HTML
+ JSP makes it possible to:
“= Use standaxd HTML tool such ae Allaise HomeSite,
‘Macromedia DeeaniVeaves, ot Adobe Golsve
— Have different members of your teamado the ETML
Iayeut than do the Java programming
+ JSP encourages you to
~ Separate the (Java) code that creates the content fiom the
(ETRE) code tat presents st
FOR PRIVATE CIRCULATION
ONLY.RE-DESIGNED FOR USIT
B.Tech STUDENTS.FOR PRIVATE CIRCULATION
ONLY.RE-DESIGNED FOR USIT
B.Tech STUDENTS.
Advantages of JSP Over
Competing Technologies
+ Versus ASP or ColdFusion
~ Better language for dynamic pat
~ Portable to wulliple servers and operating system
+ Versus PHP
~ Better language fordynanie pat
= Better tal uppast
+ Versus pure serviets
= Mone convenient to cxeate HTML
~ Canusestadand tool (eg, HomeSite)
Advantages of JSP (Continued)
+ Versus Velocity or WebMacro
=Standand
+ Versus client-side JavaScript (in browser)
~ Capabilities mostly do wot oveap with ISP, but
evens elt
Richer niga
+ Versus server-side JavaScript
(eg, LiveWire, BroadVision, Sun)
erlang
: eps 5 static HTML
~Dinde al commer
THgP propane sll need io lao me fea no nger
seret propane aoe ‘deco
Setting Up Your Environment Example
inet VOM CEASE ATL Not: SSNENTESRCS Pact Poca} rect oof enen eon Pea
+ Compile your code. Not. vente ve
+ Use packages to avoid name conflicts. Not. =
+ Put JSP page in special directory. Not.
~ inutall_dirbwabapps\ROOT (HTML and ISP ~ Toweat)
inatall_d verve Wefealtdefnalt-app (3
~ Some Serves reserve certain part of Web hierarchy for
JSP pages, Toneat 3 and JRun (tadaloe) doit
+ Use special URL to invoke JSP page. Not.
+ Caveats.
“Previa miles about CLASSPATH, aval di, ete, sl
apply to regular Java classes used by a ISP page
Srimubose taprasstonsc/t7Lb>
srereenc/one>
FOR PRIVATE CIRCULATION
ONLY.RE-DESIGNED FOR USIT
B.Tech STUDENTS.FOR PRIVATE CIRCULATION
ONLY.RE-DESIGNED FOR USIT
B.Tech STUDENTS.
Example (Continued)
“Sasoce maprasstonsc/t2>
“ELbCurcent tia: che naw Java utit Datat) >
os
Sao
cana
Example Result
+ Iflocation was
~C Nakartactomeat-4 Owrebapps\ROOTExpession jsp or
= C AProgram Files\Alaive Runverver:Wefaul
Adefaaltapp Expression: jp
+ URL would be
Most Common Misunderstanding
Forgetting JSP is Server-Side Technology
+ Very common question
= Lean'tdo such and suehith HTML
‘WalJSP let me doi?
+ Why doesn’t this question make sense?
= JSP nny entzely on server
~ doesn't change content the client (bovrse) ean handle
+ Similar questions
How dol pat a nonval applet ina JSP page?
‘Anower send an fag to te client
How do I pataninage ina ISP page?
‘Anower send an fg 6 the cient
How do Lue JavaScriptAcrbatiShoclorave/Ete?
‘Anower send th appropnate HTML tags
2nd Most Common Misunderstanding
Translation/Request Time Confusion
+ What happens at page translation time?
= JSP contact: get tazlaed into sevit code
+ What happens at request time?
~ Servet code gets executed. No interpretation of SP
fees atseguest tne The ongizal ISP page = totaly
igen artes tne ony te svt teed fom
hres
+ When does page transtation occur?
~ Typically, the fst tine ISP page is accessed after itis
anodified "The should never happen to zeal cer
(Gevelopes zhould fetal ISP pager they ial).
Page tavlation doesnot aceus fr each request
FOR PRIVATE CIRCULATION
ONLY.RE-DESIGNED FOR USIT
B.Tech STUDENTS.FOR PRIVATE CIRCULATION
ONLY.RE-DESIGNED FOR USIT
B.Tech STUDENTS.
The JSP Lifecycle
FOR PRIVATE CIRCULATION
ONLY.RE-DESIGNED FOR USIT
B.Tech STUDENTS.