Sie sind auf Seite 1von 112

Web Technologies & Compiler Design Lab Record

Web Technologies
AIM:
1. Develop static pages (using Only HTML) of an online Book store. The pages should
rese!le" ###.aa$on.co. The #e!site should consist the follo#ing pages.
Hoe page
%egistration
&ser Login
Books catalog
PROCEDURE:
Main page:
'htl(
'head(
'title(hoe page')title(
')head(
'!ody(
'center('!('h1(#elcoe to aa$on.co')h1(')!('!r('!r(
'for ethod*+post+action*+login.htl+(
'input type*+su!it+value*+click+(registration user login hear
')center(
')!ody(
')htl(
Login page:
'htl(
'head(
'title(login page')title(
')head(
'!ody(
'center(
'for ethod*+post+ action*+login.htl+(
'p('strong(nae"')strong(
'input type*+te,t+ nae*+usernae+ si$e*+-.+(
')p(
'p('strong(pass#ord')strong(
'input nae*+pass+ type*+pass#ord+ si$e*+/+(')p(
'p('strong(ale')strong(
'input type*+radio+ value*+ale+'hacked(0n!sp0n!sp')p(
'p('strong(feale')strong(
'option('input type*+radio+ value*+feale+'hacked(0n!sp1')p(
'input type*+su!it+ value*+su!it+(0n!sp0n!ps
'input type*+reset+ value*+reset+(
'a href*+registration.htl+(ne# users register hear ')a(
')for(
')center(
1
Web Technologies & Compiler Design Lab Record
')!ody(
')htl(
Regisraion:
'htl(
'head(
'title(registration')title(
')head(
'!ody(
'center(
'for ethod*+post+ action*+login.htl+(
'p('strong(nae"')strong(
'input type*+te,t+ nae*+usernae+ si$e*+-.+(
')p(
'p('strong(pass#ord')strong(
'input nae*+pass+ type*+pass#ord+ si$e*+/+(')p(
'p('strong(ale')strong(
'input type*+radio+ value*+ale+'hacked(0n!sp0n!sp')p(
'p('strong(feale')strong(
'input type*+radio+ value*+feale+ ')p(
'p('strong(address"')strong(
'te,tarea nae*+address+ ro#*+/+ cols*+-2+(
')te,tarea(
')p(
'p('strong(o!ile no"')strong(
'input type*+te,t+ nae*+phno+ si$e*+12+(
')p('!r('!r(
'input type*+su!it+ value*+su!it+(
'input type*+reset+ value*+reset+(
')for(
')center(
')!ody(
')htl(
!oo"s Caalog:
'htl(
'head(
'title(!ooks catalog')title(
')head(
'!ody(
'center('h1('p(#elcoe to !ooks catalog')p(')h1(
'ta!le !order*+1+#idth*+-.3+height*+.23+(
'tr(
'th(coputers')th(
'th(electronics')th(
'th(!iotech')th(
'th(echanical')th(
-
Web Technologies & Compiler Design Lab Record
')tr(
'tr(
'td(
')!ody(
')htl(


4
Web Technologies & Compiler Design Lab Record
5
Web Technologies & Compiler Design Lab Record
.
Web Technologies & Compiler Design Lab Record
AIM:
-. Develop static pages (using only HTML) of an online Book store. The pages
should rese!le "###.aa$on.co. The #e!site should consist the follo#ing pages.
Hoe page
%egistration and user Login
&ser profile page
Books catalog
6hopping cart
7ayent !y credit cardtt
Order 8onforation
PROCEDURE:
Main#hml:
'fraeset ro#s*9-.3: ;. 39(
/
Web Technologies & Compiler Design Lab Record
'frae src*9top.htl9 nae*9top9(
'fraeset cols*9-.3:;.39(
'frae src*9left.htl9 nae*9left9(

'frae src*9right.htl9 nae*9right9(
')fraeset(
')fraeset(
Top.htl"
'htl(
'!ody !gcolor*9pink9(
'!r('!r(
'ar<uee('h1 align*9center9('!('u(O=L>=? BOO@
6TO%AB?')u(')!(')h1(')ar<uee(
')!ody(
')htl(
Righ#hml:
'htl(
'!ody !gcolor*9pink9(
'!r('!r('!r('!r('!r(
'h- align*9center9(
'!('p( #elcoe to online !ook storage. 7ress login if you are
having id other#ise press registration.
')p(')!(')h-(
')!ody(
')htl(
Le$#hml:
'htl(
'!ody !gcolor*9pink9(
'h4(
'ul(
'li('a href*9login.htl9 target*9right9('font color*9!lack9(
LOB>=')font(')a(')li('!r('!r(
'li('a href*9reg.htl9 target*9right9('font color*9!lack9(
%?B>6T%AT>O=')font(')a(')li('!r('!r(
'li('a href*9profile.htl9 target*9right9('fontcolor*9!lack9(
&6?% 7%OC>L?')font(')a(')li('!r('!r(
'li('a href*9catalog.htl9 target*9right9('fontcolor*9!lack9(
BOO@6 8ATALOB')font(')a(')li('!r('!r(
'li('a href*9scart.htl9 target*9right9('font color*9!lack9(
6HO77>=B8A%T')font(')a(')li('!r('!r(
'li('a href*9payent.htl9 target*9right9('fontcolor*9!lack9(
7ADM?=T')font(')a(')li('!r('!r(
'li('a href*9order.htl9 target*9right9('font color*9!lack9(
O%D?% 8O=C>%MAT>O=')font(')a(')li('!r('!r(
')ul(
')!ody(
;
Web Technologies & Compiler Design Lab Record
')htl(

Login#hml:
'htl(
'!ody !gcolor*9pink9('!r('!r('!r(
'script language*9Eavascript9(
function validate()
F
var flag*11
if(docuent.yfor.id.value**9GHHdocuent.yfor.p#d.
value**9 G)
F
flag*21
I
if(flag**1)
F
alert(GJAL>D >=7&T9)1
I
else
F
alert(G>=JAL>D >=7&T9)1
docuent.yfor.focus()1
I
I
')script(
'for nae*9yfor9(
'div align*9center9('pre(
LOB>= >D"'input type*9te,t9 nae*9id9('!r(
7A66KO%D"'input type*9pass#ord9 nae*9p#d9(
')pre('!r('!r(
')div(
'!r('!r(
'div align*9center9(
'input type*9su!it9 value*9ok9 on8lick*9validate()9(0n!sp1
0n!sp10n!sp10n!sp10n!sp1'input type*9reset9 value*9clear9(
')for(
')!ody(
')htl(
Reg#hml:
'htl(
'!ody !gcolor*9pink9('!r('!r(
'script language*9Eavascript9(
function validate()
F
var flag*11
if(docuent.yfor.nae.value**99HH
L
Web Technologies & Compiler Design Lab Record
docuent.yfor.addr.value**99HH
docuent.yfor.phno.value**99HH
docuent.yfor.id.value**99HH
docuent.yfor.p#d.value**99)
F
flag*21
I
var str*docuent.yfor.phno.value1
var ,1
for(var i*21i'str.length1iMM)
F
,*str.su!str(i:1)
if(N(,'*O))
F
flag*21
!reak1

I
I
if(flag**1)
F
alert(+JAL>D >=7&T+)1
I
else
F
alert(+>=JAL>D >=7&T+)1
docuent.yfor.focus()1
I
I
')script(
'for nae*+yfor+(
'div align*+center+('pre(
=AM?"'input type*+te,t+ nae*+nae+('!r(
ADD%?66"'input type*+type+ nae*+addr+('!r(
8O=TA8T =&MB?%"'iput type*+te,t+ nae*+phno+('!r(
LOB>=>D"'input type*+te,t+ nae*+id+('!r(
7A66KO%D"'input type*+pass#ord+ nae*+p#d+(')pre('!r('!r(
')div(
'!r('!r(
'div align*+center+(
'input type*+su!it+ value*+ok+ on8lick*+validate()+(0n!sp10n!sp10n!sp1
'input type*+reset+ value*+clear+(
')for(')!ody(')htl(
Caalog#hml:
'htl(
'!ody !gcolor*+pink+('!r('!r('!r(
O
Web Technologies & Compiler Design Lab Record
'div align*+center+('pre(
BOO@ T>TL? "'input type*+te,t+ nae*+title+('!r(
')pre('!r('!r(
')div(
'!r('!r(
'div align*+center+(
'input type*+su!it+ value*+ok+ nae*+!utton1+(0n!sp10n!sp10n!sp10n!sp1
'input type*+reset+ value*+clear+ nae*+!utton-+(
')!ody(
')htl(

Order#hml:
'htl(
'!ody !gcolor*+pink+('!r('!r('!r(
'div align*+center+('pre(
LOB>= >D"'input type*+te,t+ nae*+id+('!r(
T>TL?"'input type*+te,t+ nae*+title+('!r(
=O.OC BOO@6 "'input type*+te,t+ nae*+no+('!r(
8O6T OC BOO@"'input type*+te,t+nae*+cost+('!r(
DAT?"'input tpe*+te,t+ nae*+date+('!r(')pre('!r('!r(
')div(
'!r('!r(
'div align*+center+(
'input type*+su!it+ value*+ok+ nae*+!utton1+( 0n!sp10n!sp10n!sp10n!sp1
'input type*+reset+ value*+clear+ nae*+!utton-+(
')!ody(
')htl(

Pa%men#hml:
'htl(
'!ody !gcolor*+pink+('!r('!r('!r(
'script language*+Eavascript+(
function validate()
F
var flag*11
if(docuent.yfor.id.value**++HH
docuent.yfor.p#d.value**++HH
docuent.yfor.aount.value**++HH
docuent.yfor.nu.value**++)
F
flag*21
I
var str*docuent.yfor.aount.value1
var ,1
for(var i*21i'str.length1iMM)
F
,*str.su!str(i:1)1
12
Web Technologies & Compiler Design Lab Record
if(N(,'*O))
F
flag*21
!reak1
I

I
str*docuent.yfor.nu.value1
for(var i*21i'str.lenght1iMM)
F
,*str.su!str(i:1)1
if(N(,'*O))
F
flag*21
!reak1
I
I
if(flag**1)
F
alert(+JAL>D >=7&T+)1
I
else
F
alert(+>=JAL>D >=7&T+)1
docuent.yfor.focus()1
I
I
')script(
'for nae*+yfor+(
'div align*+center+('pre(
LOB>= >D"'input type*+te,t+ nae*+id+('!r(
7A66KO%D"'input type*+pass#ord+ nae*+p#d+('!r(
AMO&=T"'input type*+te,t+ nae*+aount+('!r(
8%?D>T8A%D=&MB?%"'input type*+7A66KO%D+ nae*+nuM+('!r(')pre('!r('!r(
')div(
'!r('!r(
'div align*+center+(
'input type*+su!it+ value*+ok+ on8lick*+validate()+(0n!sp10n!sp10n!sp10n!sp1
'input type*+reset+ value*+clear+ (
')for(
')!ody(
')htl(

Pro$ile#hml:
'htl(
'!ody !gcolor*+pink+('!r('!r('!r(
'script language*+Eavascript+(
11
Web Technologies & Compiler Design Lab Record
function validate()
F
var flag*11
if(docuent.yfor.id.value**++HH
docuent.yfor.p#d.value**++)
F
flag*21
I
if(flag**1)
F
alert(+JAL>D >=7&T+)1
I
else
F
alert(+>=JAL>D >=7&T+)1
docuent.yfor.focus()1
I
I
')script(
'for nae*+yfor+(
'div align*+center+('pre(

LOB>= >D "'input type*+te,t+ nae*+id+('!r(
7A66KO%D"'input type*+pass#ord+ nae*+p#d+(')pre('!r('!r(
')div(
'!r('!r(
'div align*+center+(
'input type*+su!it+ value*+ok+ on8lick*+validate()+(0n!sp10n!sp10n!sp10n!sp1
'input type*+reset+ value*+clear+ (
')for(
')!ody(
')htl(
1-
Web Technologies & Compiler Design Lab Record
14
Web Technologies & Compiler Design Lab Record
15
Web Technologies & Compiler Design Lab Record
1.
Web Technologies & Compiler Design Lab Record
1/
Web Technologies & Compiler Design Lab Record
1;
Web Technologies & Compiler Design Lab Record
AIM:
&# To do validation for registration page using Pava6cript.
DE'CRIPTIO(: Krite JavaScript to validate the follo#ing fields of the a!ove
%egistration page.
1. =ae (=ae should contains alpha!ets and the length should not !e less than /
characters).
-. 7ass#ord (7ass#ord should not !e less than / characters length).
4. ?Qail id (should not contain any invalid and ust follo# the standard pattern
(naeRdoain.co)
5. 7hone nu!er (7hone nu!er should contain 12 digits only).

=ote" Dou can also validate the login page #ith these paraeters.
)alidaion#hml
'htl(
'head(
'title(%egistration')title(
'script type*+te,t)Eavascript+(
function validate()
F
var c1*ne# %eg?,p(+STUU#VF/:IW+)1
var c-*ne# %eg?,p(+STUU#VF/:IW+)1
var c4*ne# %eg?,p(+STUU#VMRTUU#VM.coW+)1
var c5*ne# %eg?,p(+STUUdVF12IW+)1
var nae*docuent.f.user.value1
var p#d*docuent.f.p#d.value1
var eail*docuent.f.eail.value1
var phone*docuent.f.phone.value1
var error*++1
if(Nnae.atch(c1))
F errorM*+should !e in of / charUn+ I
if(Np#d.atch(c-))
F
errorM*+should !e in of / charUn+
I
if(Neail.atch(c4))
F
1L
Web Technologies & Compiler Design Lab Record
errorM*+should !e of forat naeRdoain.coUn+
I
if(Nphone.atch(c5))
F
errorM*+should !e of 12 digits+
I
#indo#.alert(error)1
I
')script(
')head(
'!ody !gcolor*X;DO?82(
'center(
'for nae*f(
'ta!le align*center !order*2 #idth*/.3 height*1223(
'caption align*center( %?B>6T%AT>O= CO%M ')caption(
'tr (
'td(&ser=ae "')td(
'td ( 'input type*te,t nae*user(')td(
')td(
')tr(
'tr(
'td(7ass#ord"')td(
'td ('input type*pass#ord nae*p#d(')td(

')tr(
'tr (
'td(?Qail id"')td(
'td ('input type*te,t nae*eail(')td(

')tr(
'tr(
'td(7hone =u!er"')td(
'td ('input type*te,t nae*phone(')td(
'td( 'p id* +ph+( ')p(')td(
')tr(
'tr(
'td('input type*!utton value*+6u!it+ onclick*validate()(')td(
'td('input type*reset value*+%eset+(')td(
')tr(
')ta!le(
')for(
')!ody(
')htl(
1O
Web Technologies & Compiler Design Lab Record
O*p* :

AIM
5. Krite a progra illustrating various ethods in cascading style sheets.
1) &se different font: styles
-) 6et a !ackground iage
4) 8ontrol the repetition of the iage
5) Define styles for links
-2
Web Technologies & Compiler Design Lab Record
.) Kork #ith layers
/) Add a custoi$ed cursor
DE'CRIPTIO(: Design a #e! page using C'' +Cascading 'tyle 'heets, #hich
includes the follo#ing"
1) &se different font: styles" >n the style definition you define ho# each selector should
#ork (font: color etc.).Then: in the !ody of your pages: you refer to these selectors to
activate the styles.
2) Set a background image for both the page and single elements on the page. You can define the
background image for the page like this:
4) 8ontrol the repetition of the iage #ith the !ackgroundQrepeat property.
As !ackgroundQrepeat" repeat
5) Define styles for links as
.) Kork #ith layers"
/) Add a custoi$ed cursor"
6elector Fcursor"valueI
.,link Fcursor"crosshairI
.hlinkFcursor"helpI
-# .on s%les
'htl(
'head(
'title( styles')title(
-1
Web Technologies & Compiler Design Lab Record
'style type*+te,t)css+(
!.headline Fcolor"red1fontQsi$e"--pt1fontQfaily"arial1te,tQdecoration"noneI
')style(
')head(
'!ody(
'!( this is noral !old')!( '!r )(
'! class*+headline+( this is headline style !old')!(
')!ody(
')htl(
O*p* 'creen:
--
Web Technologies & Compiler Design Lab Record

/# !ac"gro*nd image
'htl(
'head(
-4
Web Technologies & Compiler Design Lab Record
'style(
!odyF !ackgroundQiage"url(+#inter.Epg+)1I
ta!le
F !ackgroundQiage"url(#ater lilies.Epg)1I
')style(
'!ody (
'ta!le !order*- #idth*.23 height*.23 align*center(
'tr(
'td( slno')td(
'td( nae ')td(
')tr(
'tr(
'td( 1')td(
'td( raE')td( ')tr(
'tr( 'td( -')td(
'td( kuar')td( ')tr(
')ta!le(')!ody(')htl(
O*p* 'creens:
-5
Web Technologies & Compiler Design Lab Record

&# Conrol repea
'htl(
'head(
-.
Web Technologies & Compiler Design Lab Record
'style(
!odyF
!ackgroundQiage"url(#inter.Epg)1
!ackgroundQrepeat"noQrepeat1
I
')style(
')head(
')!ody(
'h-( this is the !ody of the page #here the iage is repeated')h-(
')!ody(
')htl(
O*p* 'creen:
-/
Web Technologies & Compiler Design Lab Record

0# Di$$eren %pes o$ lin"s
'htl(
'head(
-;
Web Technologies & Compiler Design Lab Record
'style type*+te,t)css+(
a"link Fte,tQdecoration"underline1color*redI
a"activeF te,tQdecoration1OJ?%L>=?18OLO%"greenI
a"visitedF te,tQdecoration18OLO%"yello#I
a"hoverF te,tQdecoration"overline1 color*greenI
')style(')head(
'!ody(
'h-( these are links ')h-(
'a href*L>=@6TDL?6.htl (L>=@1')a('!r )('!r )('!r )(
'a href*L>=@6TDL?6.htl (L>=@-')a('!r )('!r )('!r )(
'a href*4.htl (L>=@4')a('!r )('!r )('!r )(
'a href*5.htl (L>=@5')a('!r )(
')!ody(')htl(
O*p* 'creens:
-L
Web Technologies & Compiler Design Lab Record

1# Wor" 2ih la%ers
'htl(
'head(
-O
Web Technologies & Compiler Design Lab Record
'title( KO%@>=B K>TH LAD?%6')T>TL?(
')head(
'!ody(
'div style*+position" a!solute1top" .2p,1left" .p,1$Qinde," -1fontQ
si$e".27Y1color"red+(LAD?% 1 ')div(
'div style*+position" a!solute1top" ;2p,1left" .2p,1$Qinde," 11fontQ
si$e".27Y1color"green+(LAD?% - ')div(
')!ody(
')htl(
O*p* 'creens:

AIM :
1.De3eloping a 'imple !ean Using he !D4:
This section presents an e,aple that sho#s ho# to develop a siple Bean and connect it to
other coponents via the BD@.
Our ne# coponent is called the Colors Bean. >t appears as either a rectangle or
ellipse that is filled #ith a color. A color is chosen at rando #hen the Bean !egins
42
Web Technologies & Compiler Design Lab Record
e,ecution. A pu!lic ethod can !e invoked to change it. ?ach tie the ouse is clicked
on the Bean: another rando color is chosen. There is one boolean read)#rite property
that deterines the shape.
The BD@ is used to lay out an application #ith one instance of the Colors Bean and
one instance of the O*r!*on Bean. The !utton is la!eled G8hange.9 ?ach tie it is
pressed: the color changes.
6OCTKA%? D?J?LO7M?=T &6>=B PAJA
8reate a =e# Bean
Here are the steps that you ust follo# to create a ne# Bean"
1. 8reate a directory for the ne# Bean.
-. 8reate the Pava source file(s).
4. 8opile the source file(s).
5. 8reate a anifest file.
.. Benerate a PA% file.
/. 6tart the BD@.
;. Test.
The follo#ing sections discuss each of these steps in detail.
8reate a Directory for the =e# Bean
Dou need to ake a directory for the Bean. To follo# along #ith this e,aple: create
c:5bd"5demo5s*n25demo5colors. Then change to that directory.
The 8olors and OurButton Beans
8reate the 6ource Cile for the =e# Bean
The source code for the Colors coponent is sho#n in the follo#ing listing. >t is
located in the file Colors#6a3a.
The impor stateent at the !eginning of the file places it in the package naed
s*n2#demo#colors. %ecall fro 8hapter O that the directory hierarchy corresponds to
the package hierarchy. Therefore: this file ust !e located in a su!directory naed
s*n25demo5colors relative to the CLA''PAT7 environent varia!le.
The color of the coponent is deterined !y the private Color varia!le color: and
its shape is deterined !y the private boolean varia!le recang*lar.
The constructor defines an anonyous inner class that e,tends Mo*seAdaper and
overrides its mo*sePressed+ , ethod. The change+ , ethod is invoked in response to
ouse presses. The coponent is initiali$ed to a rectangular shape of -22 !y 122 pi,els.
The change+ , ethod is invoked to select a rando color and repaint the coponent.
The geRecang*lar+ , and seRecang*lar+ , ethods provide access to the one
property of this Bean. The change+ , ethod calls randomColor+ , to choose a color and
then calls repain+ , to ake the change visi!le. =otice that the pain+ , ethod uses the
recang*lar and color varia!les to deterine ho# to present the Bean.
41
Web Technologies & Compiler Design Lab Record
)) A siple Bean.
package sun#.deo.colors1
iport Eava.a#t.Z1
iport Eava.a#t.event.Z1
pu!lic class 8olors e,tends 8anvas F
transient private 8olor color1
private !oolean rectangular1
pu!lic 8olors() F
addMouseListener(ne# MouseAdapter() F
pu!lic void ouse7ressed(Mouse?vent e) F
change()1
I
I)1
rectangular * false1
set6i$e(-22: 122)1
change()1
I
pu!lic !oolean get%ectangular() F
return rectangular1
I
pu!lic void set%ectangular(!oolean flag) F
this.rectangular * flag1
repaint()1
I
pu!lic void change() F
6OCTKA%? D?J?LO7M?=T
&6>=B PAJA
color * rando8olor()1
repaint()1
I
private 8olor rando8olor() F
int r * (int)(-..ZMath.rando())1
int g * (int)(-..ZMath.rando())1
int ! * (int)(-..ZMath.rando())1
return ne# 8olor(r: g: !)1
I
pu!lic void paint(Braphics g) F
Diension d * get6i$e()1
int h * d.height1
int # * d.#idth1
g.set8olor(color)1
if(rectangular) F
g.fill%ect(2: 2: #Q1: hQ1)1
I
else F
g.fillOval(2: 2: #Q1: hQ1)1
4-
Web Technologies & Compiler Design Lab Record
I
I
I
8opile the 6ource 8ode for the =e# Bean
8opile the source code to create a class file. Type the follo#ing"
Eavac 8olors.Eava.
8reate a Manifest Cile.
Dou ust no# create a anifest file. Cirst: s#itch to the c:5bd"5demo directory. This
is the directory in #hich the anifest files for the BD@ deos are located. 7ut the
source code for your anifest file in the file colors#m$. >t is sho#n here"
=ae" sun#)deo)colors)8olors.class
PavaQBean" True
This file indicates that there is one #class file in the PA% file and that it is a Pava Bean.
=otice that the Colors#class file is in the package s*n2#demo#colors and in the
su!directory s*n25demo5colors relative to the current directory.
Benerate a PA% Cile
Beans are included in the ToolBo, #indo# of the BD@ only if they are in PA% files in the
directory c:5bd"56ars. These files are generated #ith the Ear utility. ?nter the follo#ing"
Ear cf ..UEarsUcolors.Ear colors.ft sun#UdeoUcolorsUZ.class
This coand creates the file colors#6ar and places it in the directory c:5bd"56ars.
(Dou ay #ish to put this in a !atch file for future use.)
6tart the BD@
8hange to the directory c:5bd"5beanbo8 and type r*n. This causes the BD@ to start.
Dou should see three #indo#s: titled ToolBo,: BeanBo,: and 7roperties. The ToolBo,
#indo# should include an entry la!eled G8olors9 for your ne# Bean.
8reate an >nstance of the 8olors Bean
After you coplete the preceding steps: create an instance of the Colors Bean in the
BeanBo, #indo#. Test your ne# coponent !y pressing the ouse any#here #ithin
its !orders. >ts color iediately changes. &se the 7roperties #indo# to change the
recang*lar property fro $alse to r*e. >ts shape iediately changes.
8reate and 8onfigure an >nstance of the OurButton Bean
8reate an instance of the O*r!*on Bean in the BeanBo, #indo#. Then follo#
these steps"
1. Bo to the 7roperties #indo# and change the la!el of the Bean to G8hange9.
Dou should see that the !utton appearance changes iediately #hen this
property is changed.
-. Bo to the enu !ar of the BeanBo, and select ?dit H ?vents H action H
action7erfored.
4. Move the cursor so that it is inside the Colors Bean display area: and click the
left ouse !utton. Dou should see the ?vent Target Dialog dialog !o,.
5. The dialog !o, allo#s you to choose a ethod that should !e invoked #hen
44
Web Technologies & Compiler Design Lab Record
this !utton is clicked. 6elect the entry la!eled Gchange9 and click the O@ !utton.
Dou should see a essage !o, appear very !riefly: stating that the tool is
GBenerating and copiling adaptor class.9
.. 8lick on the !utton. Dou should see the color change.
Dou ight #ant to e,perient #ith the Colors Bean a !it !efore oving on.
O*p*:

8reate t#o Beans Traffic Light(ipleented as a la!el #ith only three !ackground colorsQred:
green: yello#) and Autoo!ile(>pleented as a Te,t Bo, #hich states its state)oveent).
The state of the Autoo!ile should depend on the follo#ing Light Transition ta!le.
)Z'applet code*+6ig.class+ height*422 #idth*-22(')applet(Z)
iport Eava.a#t.Z1
iport Eava.lang.6tring1
iport Eava.a#t.event.Z1
iport Eava.applet.Applet1
iport Eava.applet.Z1
pu!lic class 6ig e,tends Applet ipleents >teListenerF
!oolean c1:c-:c41
6tring s11
8heck!o, r1:r-:r41
8heck!o,Broup c!g1
pu!lic void init()F
c!g*ne# 8heck!o,Broup()1
7anel p*ne# 7anel()1
45
Web Technologies & Compiler Design Lab Record
p.setLayout(ne# BridLayout())1
add(r1*ne# 8heck!o,(+red+:c!g:false))1
add(r-*ne# 8heck!o,(+yello#+:c!g:false))1
add(r4*ne# 8heck!o,(+green+:c!g:false))1
r1.add>teListener(this)1
r-.add>teListener(this)1
r4.add>teListener(this)1
I
pu!lic void paint(Braphics g) F
g.set8olor(8olor.red)1
g.dra#Oval(12: 42: -2: -2)1
))6yste.out.println(s1)1
g.set8olor(8olor.yello#)1
g.dra#Oval(12: /2: -2: -2)1
g.set8olor(8olor.green)1
g.dra#Oval(12: O2: -2: -2)1
s1*c!g.get6elected8heck!o,().getLa!el()1
if(s1**+red+)
F
g.set8olor(8olor.red)1
g.fillOval(12: 42: -2: -2)1
I
else if(s1**+yello#+)
F
g.set8olor(8olor.yello#)1
g.fillOval(12: /2: -2: -2)1
I
else if(s1**+green+)
F
g.set8olor(8olor.green)1
g.fillOval(12: O2: -2: -2)1
I
I
pu!lic void ite6tate8hanged(>te?vent ie) F
repaint()1
I
I
4.
Web Technologies & Compiler Design Lab Record
AIM:
/. >nstall TOM8AT #e! server. 8onvert the static #e!pages of assignents - into
dynaic #e!pages using servlets and cookies. Hint" &sers inforation (user id:
pass#ord: credit card nu!er) #ould !e stored in #e!.,l. ?ach user should have
a separate 6hopping 8art.

PROCEDURE:
Cirst install the tocat into the syste.
Then ake a su!directly(eg.: tr) in the UtocatU#e!apps.
&nder tr create K?BQ>=C directory and also place the htl files in this tr directory only.
=e,t under K?BQ>=C create t#o su!classes li!:classes and #e!.,l
=e,t place all the class files under the classes and Ear files(servletQapi.Ear:classes1-.Ear
etc[) under li! su!directories.
After this start tocat !y giving the follo#ing coand at the instll\dir(tocat(!in
8atalina.!at run
At the >.?(#e! !ro#ser) give the url as http1))localhost"L2L2))tr)htlfile or servlet url
pattern
7ortno L2L2 is assigned for the tocat.
Web#8ml
'],l version*+1.2+ encoding*+isoQLL.OQ1+](
'NDO8TD7? #e!Qapp
7&BL>8 +Q))6un Microsystes: >nc.))DTD Ke! Application -.4))?=+
4/
Web Technologies & Compiler Design Lab Record
+http"))Eava.sun.co)dtd)#e!Qapp\-\4.dtd+(
'#e!Qapp(
'displayQnae(6ervlet -.5 ?,aples')displayQnae(
'description(
6ervlet -.5 ?,aples.
')description(
'servlet(
'servletQnae(reg')servletQnae(
'servletQclass(reg')servletQclass(
')servlet(
'servlet(
'servletQnae(login')servletQnae(
'servletQclass(login')servletQclass(
')servlet(

'servlet(
'servletQnae(profile')servletQnae(
'servletQclass(profile')servletQclass(
')servlet(
'servlet(
'servletQnae(catalog')servletQnae(
'servletQclass(catalog')servletQclass(
'servletQapping(
'servletQnae(order')servletQnae(
'urlQp')servlet(
'servlet(
'servletQnae(order')servletQnae(
'servletQclass(order')servletQclass(
')servlet(
attern(order')urlQpattern(
')servletQapping(
'servletQapping(
'servletQnae(catalog')servletQnae(
'urlQpattern(catalog')urlQpattern(
')servletQapping(
'servletQapping(
'servletQnae(profile')servletQnae(
'urlQpattern(profile')urlQpattern(
')servletQapping(
'servletQapping(
'servletQnae(login')servletQnae(
'urlQpattern(login')urlQpattern(
')servletQapping(
'servletQapping(
'servletQnae(reg')servletQnae(
'urlQpattern(reg')urlQpattern(
')servletQapping(
4;
Web Technologies & Compiler Design Lab Record
')#e!Qapp(

Main#hml
'NDO8TD7? htl 7&BL>8 +Q))K48))DTD YHTML 1.2 Transitional))?=+
+http"))###.#4.org)T%),htl1)DTD),htl1Qtransitional.dtd+(
'htl ,lns*+http"))###.#4.org)1OOO),htl+(
'!ody !gcolor*+pink+(
'!r )('!r )('!r )('!r )('!r )(
'h1 align*+center+('&(O=L>=? BOO@ 6TO%AB?')&(')h1('!r )('!r )('!r )(
'h- align*+center+('pre(
'!(Kelcoe to online !ook storage.
7ress LOB>= if you are having id
other#ise press %?B>6T%AT>O=
')!(')pre(')h-(
'!r )('!r )('pre(
'div align*+center+('a href*+)tr)login.htl+(LOB>=')a( 'a href*+)tr)reg.htl+(
%?B>6T%AT>O=')a(')div(')pre(
')!ody(
')htl(
Login#hml
'htl(
'!ody !gcolor*+pink+('!r )('!r )('!r )(
'for nae*+yfor+ ethod*+post+ action*+)tr)login+(
'div align*+center+('pre(
LOB>= >D "'input type*+te,t+ nae*+id+ )('!r )(
7A66KO%D "'input type*+pass#ord+ nae*+p#d+ )(')pre('!r )('!r )(
')div(
'!r )('!r )(
'div align*+center+(
'input type*+su!it+ value*+ok+ onclick*+validate()+ )(
0n!sp10n!sp10n!sp10n!sp10n!sp10n!sp1'input type*+reset+ value*+clear+ )(
')div(
')for(
')!ody(
')htl(
Reg#hml
'NDO8TD7? htl 7&BL>8 +Q))K48))DTD YHTML 1.2 Transitional))?=+
+http"))###.#4.org)T%),htl1)DTD),htl1Qtransitional.dtd+(
'htl ,lns*+http"))###.#4.org)1OOO),htl+(
'!ody !gcolor*+pink+('!r )('!r )(
'for nae*+yfor+ ethod*+post+ action*+)tr)reg+(
'div align*+center+('pre(
=AM?"'input type*+te,t+ nae*+nae+ )('!r )(
ADD%?66"'input type*+te,t+ nae*+addr+ )('!r )(
4L
Web Technologies & Compiler Design Lab Record
8O=TA8T =&MB?%"'input type*+te,t+ nae*+phno+ )('!r )(
LOB>=>D"'input type*+te,t+ nae*+id+ )('!r )(
7A66KO%D"'input type*+pass#ord+ nae*+p#d+ )(')pre('!r )('!r
)(
')div(
'!r )('!r )(
'div align*+center+(
'input type*+su!it+ value*+ok+ onclick*+validate()+ )(
0n!sp10n!sp10n!sp10n!sp10n!sp10n!sp1'input type*+reset+ value*+clear+ )(
')div(
')for(
')!ody(
')htl(
Pro$ile#hml
'NDO8TD7? htl 7&BL>8 +Q))K48))DTD YHTML 1.2 Transitional))?=+
+http"))###.#4.org)T%),htl1)DTD),htl1Qtransitional.dtd+(
'htl ,lns*+http"))###.#4.org)1OOO),htl+(
'!ody !gcolor*+pink+('!r )('!r )('!r )(
'for nae*+yfor+ ethod*+post+ action*+)tr)profile+(
'div align*+center+('pre(
LOB>= >D "'input type*+te,t+ nae*+id+ )('!r )(
')pre('!r )('!r )(
')div(
'!r )('!r )(
'div align*+center+(
'input type*+su!it+ value*+ok+ onclick*+validate()+ )(
0n!sp10n!sp10n!sp10n!sp10n!sp10n!sp1'input type*+reset+ value*+clear+ )(
')div(
')for(
')!ody(
')htl(

Caalog#hml
'NDO8TD7? htl 7&BL>8 +Q))K48))DTD YHTML 1.2 Transitional))?=+
+http"))###.#4.org)T%),htl1)DTD),htl1Qtransitional.dtd+(
'htl ,lns*+http"))###.#4.org)1OOO),htl+(
'!ody !gcolor*+pink+('!r )('!r )('!r )(
'for ethod*+post+ action*+)tr)catalog+(
'div align*+center+('pre(
BOO@ T>TL? "'input type*+te,t+ nae*+title+ )('!r )(
')pre('!r )('!r )(
')div(
'!r )('!r )(
'div align*+center+(
'input type*+su!it+ value*+ok+
nae*+!utton1+)(0n!sp10n!sp10n!sp10n!sp10n!sp10n!sp1
4O
Web Technologies & Compiler Design Lab Record
'input type*+reset+ value*+clear+ nae*+!utton-+)(
')div(
')for(
')!ody(
')htl(
Order#hml
'NDO8TD7? htl 7&BL>8 +Q))K48))DTD YHTML 1.2 Transitional))?=+
+http"))###.#4.org)T%),htl1)DTD),htl1Qtransitional.dtd+(
'htl ,lns*+http"))###.#4.org)1OOO),htl+(
'!ody !gcolor*+pink+('!r )('!r )(
'for ethod*+post+ action*+)tr)reg+(
'div align*+center+('pre(
=AM?"'input type*+te,t+ nae*+nae+ )('!r )(
7A66KO%D"'input type*+pass#ord+ nae*+p#d+ )(
T>TL?"'input type*+te,t+ nae*+title+ )('!r )(
=O. OC BOO@6"'input type*+te,t+ nae*+no+ )('!r )(
DAT?"'input type*+te,t+ nae*+date+ )('!r )(
8%?D>T 8A%D =&MB?%"'input type*+pass#ord+ nae*+cno+ )('!r )(')pre('!r
)('!r )(
')div(
'!r )('!r )(
'div align*+center+(
'input type*+su!it+ value*+ok+ nae*+!utton1+)(
0n!sp10n!sp10n!sp10n!sp10n!sp10n!sp1'input type*+reset+ value*+clear+
nae*+!utton-+)(
')div(
')for(
')!ody(
')htl(
Login#6a3a
iport Eava.s<l.Z1
iport Eava.io.Z1
iport Eava.util.Z1
iport Eava,.servlet.Z1
iport Eava,.servlet.http.Z1
pu!lic class login e,tends Http6ervlet
F
pu!lic void service(Http6ervlet%e<uest re<:Http6ervlet%esponse resp)
thro#s 6ervlet?,ception:>O?,ception
F
7rintKriter p#*resp.getKriter()1
p#.println(+'htl('!ody !gcolor*U+pinkU+)1
6tring id*re<.get7araenter(+id+)1
6tring p#d*re<.get7araeter(+p#d+)1
try
52
Web Technologies & Compiler Design Lab Record
F
Driver d*ne# oracle.Ed!c.driver.OracleDriver()1
DriverManager.registerDriver(d)1
8onnection
con*DriverManager.get8onnection(+Ed!c"oracle"thin"Rlocalhost"1
.-1"orcl+:+scott+:+tiger+)1
6tateent stt*con.create6tateent()1
6tring s<lstt*+select id:pass#ord fro login+1
%esult6et rs*stt.e,ecute^uery(s<lstt)1
int flag*21
#hile(rs.ne,t())
F
if(id.e<ual(rs.get6tring(1))00p#d.e<uals(rs.get6tring(-)))
F
flag*11
I
I
if(flag**2)
F
p#.println(+6O%%D >=JAL>D >D T%D ABA>=
>D'!r('!r(+)1
p#.println(+'a href*U+)tr)login.htlU+(press LOB>= to
%?T%D')a(+)1
I
else
F
p#.println(+JAL>D LOB>= >D'!r('!r(+)1
p#.println(+'h4('ul(+)1
p#.println(+'li('ahref*U+profile.htlU+('fontcolor*U+!lac
kU+(&6?% 7%OC>L?')font(')a(')li('!r('!r(+)1

p#.println(+'li('ahref*U+catalog.htlU+('fontcolor*U+!lackU+(BO
O@6 8ATALOB')font(')a(')li('!r('!r(+)1
p#.println(+'li('ahref*U+order.htlU+('fontcolor*U+!lackU+(O%D
?% 8O=C>%MAT>O=')font(')a(')li('!r('!r(+)1
I
p#.println(+')!ody(')htl(+)1
I
catch(?,ception e)
F
resp.send?rror(.22:e.to6tring())1
I
I
I
51
Web Technologies & Compiler Design Lab Record
Reg#hml
iport Eava.s<l.Z1
iport Eava.io.Z1
iport Eava.util.Z1
iport Eava,.servlet.Z1
iport Eava,.servlet.http.Z1
pu!lic class login e,tends Http6ervlet
F
pu!lic void service(Http6ervlet%e<uest re<:Http6ervlet%esponse resp)
thro#s 6ervlet?,ception:>O?,ception
F
7rintKriter p#*resp.getKriter()1
p#.println(+'htl('!ody !gcolor*U+pinkU+)1
6tring nae*re<.get7araenter(+nae+)1
6tring addr*re<.get7araeter(+addr+)1
6tring phno*re<.get7araeter(+phno+)1
6tring id*re<.get7araenter(+id+)1
6tring p#d*re<.get7araeter(+p#d+)1

int no*>nteger.parse>nt(phno)1
try
F
Driver d*ne# oracle.Ed!c.driver.OracleDriver()1
DriverManager.registerDriver(d)1
8onnection
con*DriverManager.get8onnection(+Ed!c"oracle"thin"Rlocalhost"1
.-1"orcl+:+scott+:+tiger+)1
6tateent stt*con.create6tateent()1
6tring s<lstt*+select id:pass#ord fro login+1
%esult6et rs*stt.e,ecute^uery(s<lstt)1
int flag*21
#hile(rs.ne,t())
F
if(id.e<ual(rs.get6tring(1))00p#d.e<uals(rs.get6tring(-)))
F
flag*11
I
I
if(flag**1)
F
p#.println(+6O%%D >=JAL>D >D AL%?ADD ?Y>T6 T%D
ABA>= K>TH =?K >D'!r('!r(+)1
p#.println(+'a href*U+)tr)reg.htlU+(press %?B>6T?% to
%?T%D')a(+)1
I
else
F
5-
Web Technologies & Compiler Design Lab Record
6tateent stt1*con.create6tateent()1
stt1.e,ecute&pdate(+insertintologin
values(+Mnaes+:+MaddrM+:+MnoM+:+MidM+:+Mp#dM+)+)1
p#.println(+DO&% D?TA>L6 A%?
?=T?%?D'!r('!r(+)1
p#.println(+'a href*U+)tr)login.htlU+(press LOB>= to
login')a(+)1
I
p#.println(+')!ody(')htl(+)1
I
catch(?,ception e)
F
resp.send?rror(.22:e.to6tring())1
I
I
I

Calog#6a3a
iport Eava.s<l.Z1
iport Eava.io.Z1
iport Eava.util.Z1
iport Eava,.servlet.Z1
iport Eava,.servlet.http.Z1
pu!lic class login e,tends Http6ervlet
F
pu!lic void service(Http6ervlet%e<uest re<:Http6ervlet%esponse resp)
thro#s 6ervlet?,ception:>O?,ception
F
7rintKriter p#*resp.getKriter()1
p#.println(+'htl('!ody !gcolor*U+pinkU+)1
6tring title*re<.get7araeter(+title+)1
try
F
Driver d*ne# oracle.Ed!c.driver.OracleDriver()1
DriverManager.registerDriver(d)1
8onnection
con*DriverManager.get8onnection(+Ed!c"oracle"thin"Rlocalhost"1
.-1"orcl+:+scott+:+tiger+)1
6tateent stt*con.create6tateent()1
6tring s<lstt*+select id:pass#ord fro login+1
%esult6et rs*stt.e,ecute^uery(s<lstt)1
int flag*21
#hile(rs.ne,t())
F
p#.println(+:div align*U+centerU+(+)1
p#.println(+T>TL?"+Mrs.get6tring(1)M+'!r(+)1
p#.println(+A&THO%"+Mrs.get6tring(-)M+'!r(+)1
54
Web Technologies & Compiler Design Lab Record
p#.println(+J?%6>O="+Mrs.get6tring(4)M+'!r(+)1
p#.println(+7&BL>6H?%"+Mrs.get6tring(5)M+'!r(+)1
p#.println(+8O6T"+Mrs.get6tring(.)M+'!r(+)1

p#.println(+')div+)1
flag*11
I
if(flag**2)
F
p#.println(+6O%%D >=JAL>D T>TL? T%D ABA>=
'!r('!r(+)1
p#.println(+'a href*U+)tr)catalog.htlU+(press H?%? to
%?T%D')a(+)1
I
p#.println(+')!ody(')htl(+)1
I
catch(?,ception e)
F
resp.send?rror(.22:e.to6tring())1
I
I
I
Pro$ile#6a3a
iport Eava.s<l.Z1
iport Eava.io.Z1
iport Eava.util.Z1
iport Eava,.servlet.Z1
iport Eava,.servlet.http.Z1
pu!lic class login e,tends Http6ervlet

F
pu!lic void service(Http6ervlet%e<uest re<:Http6ervlet%esponse resp)
thro#s 6ervlet?,ception:>O?,ception
F
7rintKriter p#*resp.getKriter()1
p#.println(+'htl('!ody !gcolor*U+pinkU+)1
6tring id*re<.get7araenter(+id+)1
try
F
Driver d*ne# oracle.Ed!c.driver.OracleDriver()1
DriverManager.registerDriver(d)1
8onnection con*DriverManager.get8onnection(+Ed!c"oracle"thin"
Rlocalhost"1.-1"orcl+:+scott+:+tiger+)1
6tateent stt*con.create6tateent()1
55
Web Technologies & Compiler Design Lab Record
6tring s<lstt*+select Z fro login #here id*+MidM++1
%esult6et rs*stt.e,ecute^uery(s<lstt)1
int flag*21
p#.println(+'!r('!r('!r(+)1
#hile(rs.ne,t())
F
p#.println(+'div align*U+centerU+(+)1
p#.println(+=AM? "+Mrs.get6tring(1)M+'!r(+)1
p#.println(+ADD%?66"+Mrs.get6tring(-)M+'!r(+)1
p#.println(+7HO=? =O"+Mrs.get6tring(4)M+'!r(+)1
p#.println(+')div(+)1
flag*11
I
if(flag**2)
F
p#.println(+6O%%D >=JAL>D >D T%D ABA>=
>D'!r('!r(+)1
p#.println(+'a href*U+)tr)profile.htlU+(press H?%? to
%?T%D')a(+)1
I
p#.println(+')!ody(')htl(+)1
I
catch(?,ception e)
F
resp.send?rror(.22:e.to6tring())1
I
I
I

Order#6a3a
iport Eava.s<l.Z1
iport Eava.io.Z1
iport Eava.util.Z1
iport Eava,.servlet.Z1
iport Eava,.servlet.http.Z1
pu!lic class login e,tends Http6ervlet
F
pu!lic void service(Http6ervlet%e<uest re<:Http6ervlet%esponse resp)
thro#s 6ervlet?,ception:>O?,ception
F
7rintKriter p#*resp.getKriter()1
p#.println(+'htl('!ody !gcolor*U+pinkU+)1
6tring id*re<.get7araenter(+id+)1
6tring p#d*re<.get7araeter(+p#d+)1
6tring title*re<.get7araeter(+title+)1
5.
Web Technologies & Compiler Design Lab Record
6tring count1*re<.get7araeter(+no+)1
6tring date*re<.get7araeter(+date+)1
6tring cno*re<.get7araeter(+cno+)1
int count*>nteger.parse>nt(count1)1
try
F
Driver d*ne# oracle.Ed!c.driver.OracleDriver()1
DriverManager.registerDriver(d)1
8onnection
con*DriverManager.get8onnection(+Ed!c"oracle"thin"Rlocalhost"1
.-1"orcl+:+scott+:+tiger+)1

6tateent stt*con.create6tateent()1
6tring s<lstt*+select id:pass#ord fro login+1
%esult6et rs*stt.e,ecute^uery(s<lstt)1
int flag*2:aount:,1
#hile(rs.ne,t())
F
if(id.e<uals(rs.get6tring(1))00p#d.e<uals(rs.get6tring(-)))
F
flag*11
I
I
if(flag**2)
F
p#.println(+6O%%D >=JAL>D >D T%D ABA>=
>D'!r('!r(+)1
p#.println(+'a href*UU+)tr)order.htlUU+(press H?%? to
%?T%D')a(+)1
I
else
F
6tateent stt-*con.create6tateent()1
6tring s*+select cost fro !ook #here title*+MtitleM++1
%esult6et rs1*stt-.e,ecute^uery(s)1
int flag1*21
#hile(rs1.ne,t())
F
flag1*11
,*>nteger.parse>nt(rs1.get6tring(1))1
aount*countZ,1
p#.println(+AMO&=T
"+MaountM+'!r('!r('!r('!r(+)1
6tateent stt1*con.create6tateent()1
stt1.e,ecute&pdate(+insertintodetails
values(_+MidM+:_+MtitleM+_MaountM_+:+_McnoM_+)+_)1
p#.println(+DO&% O%D?% has taken'!r(+)1
5/
Web Technologies & Compiler Design Lab Record
I
if(flag1**2)
F
p#.println(+6O%%D >=JAL>D >D T%D ABA>=
>D'!r('!r(+)1
p#.println(+'a href*UU+)tr)order.htlUU+(press H?%? to
%?T%D')a(+)1
I
I
p#.println(+')!ody(')htl(+)1
con.close()1

I
catch(?,ception e)
F
resp.send?rror(.22:e.to6tring())1
I
I
O*p* :

5;
Web Technologies & Compiler Design Lab Record
5L
Web Technologies & Compiler Design Lab Record
5O
Web Technologies & Compiler Design Lab Record
AIM:
;. %edo the previous task using P67 !y converting the static #e! pages of assignents - into
dynaic #e! pages. 8reate a data!ase #ith user inforation and !ooks inforation and !ooks
inforation. The !ooks catalogue should !e dynaically loaded fro the data!ase. Collo# the
MJ8 architecture #hile doing the #e!site.
PROCEDURE:
1) 8reate your o#n directory under tocat)#e!apps (e.g. tr1)
-) 8opy the htl files in tr1
4) 8opy the Esp files also into tr1
5) 6tart tocat give the follo#ing coand 8atalina.!at run
.) At installQdir)!in at >.? give url as http"))localhost"L2L1)tr1)ain.htl
Main#hml:
'htl(
'!ody !gcolor*9pink9(
'!r('!r('!r('!r('!r('!r(
'h1 align*9center9((&(O=L>=? BOO@ 6TO%AB?')u(')h1('!r('!r('!r(
'h- align*9center9('7%?(
'!( Kelcoe to online !ook storage.
7ress LOB>= if you are having id
Other#ise press %?B>6T%AT>O=
.2
Web Technologies & Compiler Design Lab Record
')!(')7%?(')h-(
'!r('!r('pre(
'div align*9center9('a href*9)tr)login.htl9(LOB>=')a(
href*9)tr)login.htl9(%?B>6T%AT>O=')a(')div(')pre(
')!ody(')htl(

Login#hml:
'htl(
'!ody !gcolor*9pink9('!r('!r('!r(
'for nae*+yfor+ ethod*+post+ action*)tr1)login.Esp+(
'div align*+center+('pre(
LOB>= >D " 'input type*+pass#ors+ nae*+p#d+(')pre('!r('!r(
7A66KO%D " 'input type*+pass#ord+ nae*+p#d+(')pre('!r('!r(
')div(
'!r('!r(
'div align*+center+(
'inputtype*+su!it+value*+ok+
on8lick*+validate()+(0n!sp10n!sp10n!sp10n!sp10n!sp1'input type*+reset+ value*+clear+(
')for(
')!ody(
')htl(

Reg#hml:
'htl(
'!ody !gcolor*+pink+('!r('!r(
'for nae*+yfor+ ethod*+post+ action*+)tr1)reg.Esp+(
'div align*+center+('pre(
=AM?"'input type*+te,t+ nae*+nae+('!r(
ADD%?66 "'input type*+te,t+ nae*+addr+('!r(
8O=TA8T =&MB?% " 'input type*+te,t+ nae*+phno+('!r(
LOB>= >D " 'input type*+te,t+ nae*+id+('!r(
7A66KO%D " 'input type*+pass#ord+ nae*+p#d+(')pre('!r('!r(
')div(
'!r('!r(
'div align*+center+(
'inputtype*+su!it+value*+ok+
on8lick*+validate()+(()+(0n!sp10n!sp10n!sp10n!sp10n!sp1'input type*+reset+
value*+clear+(
')for(
')!ody(
')htl(

Pro$ile#hml:
'htl(
.1
Web Technologies & Compiler Design Lab Record
'!ody !gcolor*+pink+('!r('!r(
'for nae*+yfor+ ethod*+post+ action*+)tr1)profile.Esp+(
'div align*+center+('pre(
LOB>= >D " 'input type*+te,t+ nae*+id+('!r(
')pre('!r('!r(
')div(
'!r('!r(
'div align*+center+(
'inputtype*+su!it+value*+ok+
on8lick*+validate()+(()+(0n!sp10n!sp10n!sp10n!sp10n!sp1'input type*+reset+
value*+clear+(
')for(
')!ody(
')htl(

Caalog#hml:
'htl(
'!ody !gcolor*+pink+('!r('!r('!r(
'for ethod*+post+ action*+)tr1)catalog.Esp+(
'div align*+center+('pre(
BOO@ T>TL? " 'input type*+te,t+ nae*+title+('!r(
')pre('!r('!r(
')div(
'!r('!r(
'div align*+center+(
'inputtype*+su!it+value*+ok+
nae*9!utton19(0n!sp10n!sp10n!sp10n!sp10n!sp1'inputtype*+reset+value*+clear+
nae*9!utton-9(
')for(
')!ody(
')htl(

Order#hml:
'htl(
'!ody !gcolor*+pink+('!r('!r('!r(
'for ethod*+post+ action*+)tr1)order.Esp+(
'div align*+center+('pre(
LOB>= >D"'input type*+te,t+ nae*+id+('!r(
7A66KO%D " 'input type*+pass#ord+ nae*+p#d+('!r(
T>TL?"'input type*+te,t+ nae*+title+('!r(
=O. OC BOO@6 " 'input type*+te,t+ nae*+no+('!r(
DAT?" 'input type*+te,t+ nae*+date+('!r(
8%?D>T 8A%D =&MB?% " 'input type*+pass#ord+ nae*+cno+('!r(')pre('!r('!r(
')div(
'!r('!r(
'div align*+center+(
.-
Web Technologies & Compiler Design Lab Record
'input type*+su!it+ value*+ok+
nae*9!utton19(0n!sp10n!sp10n!sp10n!sp10n!sp1'input
type*+reset+ value*+clear+ nae*9!utton-9(
')for(
')!ody(
')htl(

Login#6sp:
3Rpage iport*9Eava.s<l.Z93
3Rpage iport*9Eava.io.Z93
'3
out.println(G'htl('!ody !gcolor*U9pinkU9(9)1
6tring id*re<uest.get7araeter(Gid9)1
6tring p#d*re<uest.get7araeter(Gp#d9)1
Driver d*ne# oracle.Ed!c.driver.OracleDriver()1
DriverManager.registerDriver(d)1
8onnection
con*DriverManager.get8onnection(GEd!c"oracle"thin"Rlocalhost"1.-1"orcl9:9scott9:9tiger9)1
6tateent stt*con.create6tateent()1
6tring s<lstt*9select id:pass#ord fro login #here id*9MidM9 and pass#ord*9Mp#dM991
%esult6et rs*stt.e,ecute^uery(s<lstt)1
int flag*21
#hile(rs.ne,t())
F
flag*11
I
if(flag**2)
F
out.println(G6O%%D >=JAL>D >D T%D ABA>= >D'!r('!r(9)1
out.println(G 'a href*U9)tr1)login.htlU9(press LOB>= to %?T%D')a(9)1
I
else
F

out.println(GJAL>D LOB>= >D'!r('!r(9)1
out.println(G'h4('ul(9)1
out.println(G'li('ahref*U9profile.htlU9('fontcolor*U9!lackU9(&6?%
7%OC>L?')font(')a(')li('!r('!r(9)1
out.println(G'li('ahref*U9catalog.htlU9('fontcolor*U9!lackU9(BOO@6
8ATALOB')font(')a(')li('!r('!r(9)1
out.println(G'li('ahref*U9order.htlU9('fontcolor*U9!lackU9(O%D?%
8O=C>%MAT>O=')font(')a(')li('!r('!r(9)1
out.println(G')ul(9)1
I
out.println(G'!ody(')htl(9)1
3(
%eg.Esp"
.4
Web Technologies & Compiler Design Lab Record
3Rpage iport*9Eava.s<l.Z93
3Rpage iport*9Eava.io.Z93
'3
out.println(G'htl('!ody !gcolor*U9pinkU9(9)1
6tring nae*re<uest.get7araeter(Gnae9)1
6tring addr*re<uest.get7araeter(Gaddr9)1
6tring phno*re<uest.get7araeter(Gphno9)1
6tring id*re<uest.get7araeter(Gid9)1
6tring p#d*re<uest.get7araeter(Gp#d9)1
int no*>nteger.parse>nt(phno)1
Driver d*ne# oracle.Ed!c.driver.OracleDriver()1
DriverManager.registerDriver(d)1
8onnection con*
DriverManager.get8onnection (GEd!c"oracle"thin"Rlocalhost"1.-1"orcl9:9scott9:9tiger9)1
6tateent stt*con.create6tateent()1
6tring s<lstt*9select id fro login91
%esult6et rs*stt.e,ecute^uery(s<lstt)1
int flag*21
#hile(rs.ne,t())
F
if(id.e<uals(rs.get6tring(1)))
F
flag*11
I
I
if(flag**1)

F
out.println(G6O%%D LOB>= >D AL%?ADD ?Y>6T6 T%D ABA>= K>TH =?K >D '!r('!r(9)1
out.println(G'a href*U9)tr1)reg.htlU9(press %?B>6T?% to %?T%D')a(9)1
I
else
F
6tateent stt1*con.create6tateent ()1
stt1.e,ecute&pdate (Ginsert into login values
(GMnaeM9:9MaddrM9:9MnoM9:9MidM9:9Mp#dM9)9)1
out.println (GDO& D?TA>L6 A%? ?=T?%?D '!r('!r(9)1
out.println (G'a href *U9)tr1)login.htlU9(press LOB>= to login')a(9)1
I
out.println (G')!ody(')htl(9)1
3(
Pro$ile#6sp:
'3Rpage iport*9Eava.s<l.Z93(
'3Rpage iport*9Eava.io.Z93(
'3
.5
Web Technologies & Compiler Design Lab Record
out.println (G'htl('!ody !gcolor*U9pinkU9(9)1
6tring id*re<uest.get7araeter(Gid9)1
Driver d*ne# oracle.Ed!c.driver.OracleDriver()1
DriverManager.regiserDriver(d)1
8onnection con*
DriverManager.get8onnection (GEd!c"oracle"thin"Rlocalhost"1.-1"orcl9:9scott9:9tiger9)1
6tateent stt*con.create6tateent ()1
6tring s<lstt*9select Z fro login #here id*9MidM991
%esult6et rs*stt.e,ecute^uery (s<lstt)1
int flag*21
#hile(rs.ne,t())
F
out.println (G'div align*U9centerU9(9)1
out.println (G=AM?"9Mrs.get6tring(1)M9'!r(9)1
out.println (GADD%?66 "9Mrs.get6tring(-)M9'!r(9)1
out.println (G7HO=? =O "9Mrs.get6tring(4)M9'!r(9)1
out.println (G')div(9)1
flag*11
I
if(flag**2)
F
out.println(G6O%%D >=JAL>D >D T%D ABA>= >D '!r('!r(9)1
out.println(G'a href*U9)tr1)profile.htlU9(press H?%? to %?T%D ')a(9)1

I
out.println (G')!ody(')htl(9)1 3(
Caalog#6sp:
'3Rpage iport*9Eava.s<l.Z93(
'3Rpage iport*9Eava.io.Z93(
'3
out.println (G'htl('!ody !gcolor*U9pinkU9(9)1
6tring title*re<uest.get7araeter (Gtitle9)1
Driver d*ne# oracle.Ed!c.driver.OracleDriver ()1
DriverManager.regiserDriver (d)1
8onnection con*
DriverManager.get8onnection (GEd!c"oracle"thin"Rlocalhost"1.-1"orcl9:9scott9:9tiger9)1
6tateent stt*con.create6tateent ()1
6tring s<lstt*9select Z fro !ook #here title*9MtitleM991
%esult6et rs*stt.e,ecute^uery (s<lstt)1
int flag*21
#hile(rs.ne,t())
F
out.println (G'div align*U9centerU9(9)1
out.println (GT>TL?"9Mrs.get6tring(1)M9'!r(9)1
out.println (GA&THO% "9Mrs.get6tring(-)M9'!r(9)1
out.println (GJ?%6>O="9Mrs.get6tring(4)M9'!r(9)1
out.println (G7&BL>6H?% "9 Mrs.get6tring(5)M9'!r(9)1
..
Web Technologies & Compiler Design Lab Record
out.println (G8O6T "9 Mrs.get6tring(.)M9'!r(9)1
out.println (G')div(9)1
flag*11
I
if(flag**2)
F
out.println(G6O%%D >=JAL>D >D T%D ABA>= >D '!r('!r(9)1
out.println(G'a href*U9)tr1)catalog.htlU9(press H?%? to %?T%D ')a(9)1
I
out.println (G')!ody(')htl(9)1
3(
Order.Esp"
'3Rpage iport*9Eava.s<l.Z93(
'3Rpage iport*9Eava.io.Z93(
'3
out.println (G'htl('!ody !gcolor*U9pinkU9(9)1
6tring id*re<uest.get7araeter (Gid9)1
6tring p#d*re<uest.get7araeter (Gp#d9)1
6tring title*re<uest.get7araeter (Gtitle9)1
6tring count1*re<uest.get7araeter (Gno9)1
6tring date*re<uest.get7araeter (Gdate9)1
6tring cno*re<uest.get7araeter (Gcno9)1
int count*>nteger.parse>nt(count1)1
Driver d*ne# oracle.Ed!c.driver.OracleDriver ()1
DriverManager.regiserDriver (d)1
8onnection con*
DriverManager.get8onnection (GEd!c"oracle"thin"Rlocalhost"1.-1"orcl9:9scott9:9tiger9)1
6tateent stt*con.create6tateent ()1
6tring s<lstt*9select id: pass#ord fro login91
%esult6et rs*stt.e,ecute^uery (s<lstt)1
int flag*2:aount:,1
#hile(rs.ne,t())
F
if(id.e<uals(rs.get6tring(1))00 p#d.e<uals(rs.get6tring(-)))
F
flag*11
I
I

if(flag**2)
F
out.println(G6O%%D >=JAL>D >D T%D ABA>= >D '!r('!r(9)1
out.println(G'a href*U9)tr1)order.htlU9(press H?%? to %?T%D ')a(9)1
I
else
F
6tateent stt-*con.create6tateent()1
./
Web Technologies & Compiler Design Lab Record
6tring s*9select cost fro !ook #here title*9MtitleM991
%esult6et rs1*stt-.e,ecute^uery(s)1
int flag1*21
#hile(rs1.ne,t())
F
flag1*11
,*>nteger.parse>nt(rs1.get6tring(1))1
aount*countZ,1
out.println(GAMO&=T "9MaountM9'!r('!r('!r('!r(9)1
6tateent stt1*con.create6tateent ()1
stt1.e,ecute&pdate (Ginsert into details
(GMidM9:9MtitleM9:9MaountM9:9MdateM9:9McnoM9)9)1
out.println (GDO& O%D?% HA6 TA@?='!r(9)1
I
if(flag1**2)
F
out.println(G6O%%D >=JAL>D BOO@ T%D ABA>= '!r('!r(9)1
out.println(G'a href*U9)tr1)order.htlU9(press H?%? to %?T%D ')a(9)1
I
Iout.println (G')!ody(')htl(9)13(





.;
Web Technologies & Compiler Design Lab Record

.L
Web Technologies & Compiler Design Lab Record
.O
Web Technologies & Compiler Design Lab Record
/2
Web Technologies & Compiler Design Lab Record
/1
Web Technologies & Compiler Design Lab Record
AIM " Krite a script for selection sort#
PRO9RAM
'htl(
'head(
'title( 6ort
')title(
'script language*+Pavascript+(
var !:i:E:tep1
var a1
a*TV1
docuent.#rite(+?nter array+)1
for(i*21i'.1iMM)
F
!*propt(+enter array eleent*+:+2+)1
aTiV*parse>nt(!)1
I
for(i*21i'.1iMM)
F
docuent.#rite(+'!r(+MaTiV)1
I
docuent.#rite(+'!r(6orted array is+)1
for(i*21i'.1iMM)
F
for(E*21E'.1EMM)
F
if(aTiV'aTEV)
F
tep*aTiV1
aTiV*aTEV1
aTEV*tep1
I
I
I
for(i*21i'.1iMM)
F
docuent.#rite(+'!r(+MaTiV)1
I
')script( ')head(')htl(
/-
Web Technologies & Compiler Design Lab Record
OUTPUT



?nter array
5
-
.
6orted array is
-
5
.
/4
Web Technologies & Compiler Design Lab Record
AIM : Krite Pava 6cript that inputs three integers fro the user and outputs their su: average:
largest. &se alert dialog !o, to display results.
PRO9RAM :
'htl( 'head( 'title( MAY ')title(
'script language*+Eavascript+(
var a:!:c:n1:n-:n4:1:-:su:avg1
a*propt(+enter 1st no*+:+ +)1
!*propt(+enter -nd no*+:+ +)1
c*propt(+enter 4rd no*+:+ +)1
n1*parse>nt(a)1
n-*parse>nt(!)1
n4*parse>nt(c)1
su*n1Mn-Mn41
avg*su)41
1*Math.a,(n1:n-)1
-*Math.a,(n4:1)1
alert(+the su is* +Msu)1
alert(+the avg is* +M-)1
alert(+the a, no is +M-)1
')script( ')head(')htl(
OUTPUT :



/5
Web Technologies & Compiler Design Lab Record



AIM : Krite a script to #rite #ord e<uivalent of a check aount.
/.
Web Technologies & Compiler Design Lab Record
PRO9RAM
'htl(
'H?AD(
'68%>7T LA=B&AB?*+Pava6cript+(
var checkflag * +false+1
function check(field)
F
if (checkflag ** +false+)
F
for (i * 21 i ' field.length1 iMM)
F
fieldTiV.checked * true1I
checkflag * +true+1
return +&ncheck All+1
I
else
F
for (i * 21 i ' field.length1 iMM)
F
fieldTiV.checked * false1
I
checkflag * +false+1
return +8heck All+1
I
I
')script(
')H?AD(
'BODD(
'center(
'for nae*yfor action*++ ethod*post(
'ta!le(
'tr('td(
'!(Dour Cavorite 6cripts 0 Languages')!('!r(
'input type*check!o, nae*list value*+1+(Pava'!r(
'input type*check!o, nae*list value*+-+(Pava6cript'!r(
'input type*check!o, nae*list value*+4+(A67'!r(
'input type*check!o, nae*list value*+5+(HTML'!r(
'input type*check!o, nae*list value*+.+(6^L'!r(
'!r(
'inputtype*!utton value*+8heck All+ on8lick*+this.value*check(this.for.list)+(
')td(')tr(
')ta!le(
')for(
')center(
')!ody(
')htl(
OUTPUT
//
Web Technologies & Compiler Design Lab Record
/;
Web Technologies & Compiler Design Lab Record
AIM : 7ractice #riting css rules.
PRO9RAM
'htl(
'head(
'title(style sheets')title(
'style type*9te,t)css9(')head(
eF!ackgroundcolor"XL222ff1color*#hiteI
h1Ffont faily"Lucida console1color"redI
pFfont si$e"42ptI
spFcolor"redI
')style(
')head(
'!ody(
'h-class*9sp9(testing')h-(
'e('h1(test')h1(')e(
'e(test1')e(
'p(test-')p(
')!ody(
')htl(
OUTPUT
testing
test
test1
test-
AIM : Krite a #e! page that displays grades of a student.
/L
Web Technologies & Compiler Design Lab Record
PRO9RAM
'htl(
'head(
'title( 6T&D?=T B%AD?6
')title(
'script language*+Eava script+(
var a:n:!:c:su*2:avg*21
!*propt(+enter student no*+:+2+)1
n*parse>nt(!)1
#hile(n'*12)
F a*propt(+enter ur grade*+:+2+)1
c*parse>nt(a)1
su*suMc1
nMM1
I
avg*su)n1
docuent.#rite(+avg is+Mavg)1
')script(
')head(')htl(
/O
Web Technologies & Compiler Design Lab Record
AIM : Krite a function that responds to a click any#here on the page.
PRO9RAM
'htl(
'!ody(
'center(
T'a href*+)+ onMouseOver*+docuent.!g8olor*_Breen_+(B%??=')a(V
T'a href*+)+ onMouseOver*+docuent.!g8olor*_%ed_+(%?D')a(V
T'a href*+)+ onMouseOver*+docuent.!g8olor*_orange_+(orange')a(V
T'a href*+)+ onMouseOver*+docuent.!g8olor*_green_+(!rightgreen')a(V
T'a href*+)+ onMouseOver*+docuent.!g8olor*_seagreen_+(seagreen')a(V
')center(
')!ody(
')htl(
;2
Web Technologies & Compiler Design Lab Record
OUTPUT


AIM : 7rogra for ipleentation of Conts.
;1
Web Technologies & Compiler Design Lab Record
PRO9RAM
'htl(
'head(
'title(Cont Test')title(
')head(
'!ody(
'!r('!('font face*9Ties =e# %oan9(Cont 8heck')font(')!(
'!r('i('font face*9Ties =e# %oan9('font si$e*5('font color*9!lack9(All
Operations')font(')i(
'!r('i('!(Bold italic check')!(')i(
')!ody(
')htl(
OUTPUT
.on Chec"
All Operations
Bold italic check
;-
Web Technologies & Compiler Design Lab Record
AIM : Krite A 7rogra for creating a ta!le.
PRO9RAM
'N code to sho# the use of ta!les(
'htl(
'head(
'title( &sing Ta!les')title(
')head(
'!ody('center(
'ta!le !order*+1+ #idth*+.+ height*+.+ !ordercolor*+red+(
'caption( 6tudent Marks ')caption(
'thead(
'tr(
'th(=ae')th(
'th(Marks')th(
')tr(
')thead(
't!ody(
'tr(
'td(alok')td(
'td(O2')td(
')tr(
;4
Web Technologies & Compiler Design Lab Record
'tr(
'td(anuE')td(
'td(O2')td(
')tr(
'tr(
'td(ankush')td(
'td(O2')td(
')tr(
')t!ody(
'tfoot(
'tr(
'th(Avg Marks')th(
'th(O2')th(
')tr(
')tfoot(
')!ody(
')htl(
OUTPUT

;5
Web Technologies & Compiler Design Lab Record
AIM : Krite A 7rogra for ipleentation of List.
PRO9RAM
'htl(
'!ody(
'ul(
'li(list1')li(
')ul('ul( 'li( P=T& KO%LD ')li(
;.
Web Technologies & Compiler Design Lab Record
'ol(
'li(>T')li(
'li(86?')li(
'li(?8?')li(
')ol(')ol(')ul(')!ody(')htl(

OUTPUT
` list1
` P=T& KO%LD
1. >T
-. 86?
4. ?8?
AIM : Krite a Eava script to copute addition of t#o nu!ers.
PRO9RAM
'htl(
'head(
'title(
Pava 6cript Add
')title(
'script language*+Eava script+(
alert(+Addition Un of t#o nu!ersN+)1
var nu1: nu-:n1:n-:su1
;/
Web Technologies & Compiler Design Lab Record
nu1*#indo#. propt(+?nter the first nu!er+:+2+)1
nu-*#indo#. propt(+?nter the second nu!er+:+2+)1
n1*parse>nt(nu1)1
n-*parse>nt(nu-)1
su*n1Mn-1
alert(+su is+Msu)1
')script(
')head(
'!ody(
')!ody(
')htl(
OUTPUT


Addiion o$ -: and /: : &:
AIM : Krite A 7rogra for ipleentation of 6#itch case.
PRO9RAM
'htl(
'head(
'title(
&6>=B TH? 6K>T8H 6TAT?M?=T
')title(
'script language *+Pavascript+(
var nu*true1var choice:ch:ft:lt:head1
choice*#indo#.propt(+ 1. BOLD -. >TAL>86 4. &=D?%L>=?D ......+:+1+)1
ch *parse>nt(choice)1
;;
Web Technologies & Compiler Design Lab Record
s#itch(ch)
F
case 1" ft*+'!(+1
lt*+')!(+1
head*+'h1( This is in BOLD ')h1(+1
!reak1
case -" ft*+'i(+1
lt*+')i(+1
head*+'h1( This is in >TAL>86 ')h1(+1
!reak1
case 4" ft*+'u(+1
lt*+')u(+1
head*+'h1( This is in &=D?%L>=?D ')h1(+1
!reak1
default " nu*false1
!reak1
I
if(nu**true)
docuent.#rite(headMftM+ 'h1(Te,t ')h1(+Mlt)1
else
docuent.#rite(+ 'h1(Krong 8hoice N try again.+)1
')script(
')head(
'!ody(
')!ody( ')htl(
OUTPUT

This is in U(DERLI(ED
Te8
;L
Web Technologies & Compiler Design Lab Record
AIM : Krite A 7rogra to find a,iu of 4 noas.
PRO9RAM
'htl(
'head( 'title( Ma,iu of =u!er ')title(
'script language *+Pavascript+(
var a:!:c:a1:!1:c1:a,1:a,-1
a*#indo#.propt(+?nter first nu!er ((+:+2+)1
!*#indo#.propt(+?nter second nu!er ((+:+1+)1
c*#indo#.propt(+?nter third nu!er ((+:+-+)1
a1*parse>nt(a)1
!1*parse>nt(!)1
c1*parse>nt(c)1
a,1*Math.a,(a:!)1
a,-*Math.a,(a,1:c)1
;O
Web Technologies & Compiler Design Lab Record
docuent.#rite(+'!r('!r('!r('center('h1(Ma,iu nu!er of +Ma1M+: +M!1M+ and
+Mc1M+ is +Ma,-)1
')script(
'!ody(')!ody(
')htl(
L2
Web Technologies & Compiler Design Lab Record
O*p*




Ma8im*m n*mber o$ ;< - and = is =
L1
Web Technologies & Compiler Design Lab Record
AIM : Krite A 7rogra for ?ntering a pass#ord.
PRO9RAM
'htl(
'head(
'title(event clicking')title(
'script language*+Eavascript+(
function pass#ord8heck()
F
var p#*ole.p#.value1
var cp#*ole.cp#.value1
if(p#N*cp#)
#indo#.alert(+%eQenter your pass#ord+)1
I
')script(')head(
'center(
'!ody font si$e*. !gcolor*+cyan+ leftargin*1-2 topargin*1-2 (
'Cor id*+ole+ on6u!it*+pass#ord8heck(this)+(
7A66KO%D"0n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp
10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp1
0n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp1
'input type*pass#ord nae*+p#+si$e*12 a, length*L ( ')input( '!r('!r('!r(
8O=C>%M
7A66KO%D0n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp10n!sp1
'input type*pass#ord nae*+cp#+si$e*12 a, length*L ( ')input( '!r('!r('!r(
'input type*+su!it+ nae*+su!+ value*+su!it+( 0n!sp1 0n!sp1
'input type*+reset+ nae*+rt+ value*+reset+(')center
')!ody(
')htl(
L-
Web Technologies & Compiler Design Lab Record
OUTPUT :

L4
Web Technologies & Compiler Design Lab Record
AIM : Krite A 7rogra for ipleentation of Tha!ola.
PRO9RAM
'htl(
'head(
'title( P 6cript ')title(
'script language*+Eavascript+(
var value1
alert(+tha!ola+)1
docuent.#riteln(+'ta!le !order*1 #idth*.23 align*center( +)1
docuent.#riteln(+'caption( Tha!ola ')caption('tr(+)1
for(var i*11i'*1.1iMM)
F
value*Math.floor(1MMath.rando()Z122)1
docuent.#riteln(+'td(+MvalueM+')td(+)1
if(i3.**2 )
docuent.#riteln(+')tr('tr(+)1
I
docuent.#riteln(+')tr(')ta!le(+)1
')script(
')head(
')htl(
OUTPUT


AIM : Krite A 7rogra for Cactorial.
PRO9RAM
L5
Web Technologies & Compiler Design Lab Record
'htl(
'head('u('center('!(%?8&%6>J? CA8TO%>AL')!('!r(')u(
'title(
factorial
')title(
'script lang*+Eavascript+(
var i:fact:a:n1
a*propt(+enter any no+:+2+)1
n*parse>nt(a)1
for (i*11i'*n1iMM)
F
res*fact(i)1
docuent.#riteln(+'!r( TH? CA8TO%>AL OC +MiM+ >6 (( +Mres)1
I
function fact(,)
F
if(,**2 HH ,**1)
return(1)1
else
return(,Zfact(,Q1))1
I
')script(
')head(
')htl(
OUTPUT

RECUR'I)E .ACTORIAL
TH? CA8TO%>AL OC 1 >6 (( 1
TH? CA8TO%>AL OC - >6 (( -
TH? CA8TO%>AL OC 4 >6 (( /
TH? CA8TO%>AL OC 5 >6 (( -5
TH? CA8TO%>AL OC . >6 (( 1-2
AIM : Krite A 7rogra for addition of t#o atrices.
PRO9RAM
'htl(
'head(
'title(Array Addition')title(
L.
Web Technologies & Compiler Design Lab Record
'script language*+Eavascript+(
var a:n:i:E:!:c1
a*TTV:TVV1
!*TTV:TVV1
c*TTV:TVV1
n*parse>nt(#indo#.propt(+?nter the array si$e+:+ +))1
#indo#.alert(+?nter the eleents in the first array+)1
for (i*21i'n1iMM)
F
for (E*21E'n1EMM)
F
aTiVTEV*parse>nt(#indo#.propt(+?nter the eleent+:++))1
I
I
#indo#.alert(+?nter the eleents in the second array+)1
for (i*21i'n1iMM)
F
for (E*21E'n1EMM)
F
!TiVTEV*parse>nt(#indo#.propt(+?nter the eleent+:++))1
I
I
docuent.#riteln(+'!r(The eleents of >st Matri, are..+)1
for (i*21i'n1iMM)
F
for (E*21E'n1EMM)
F
docuent.#riteln(aTiVTEV)1
I
I
docuent.#riteln(+'!r(The eleents of >>nd Matri, are..+)1
for (i*21i'n1iMM)
F
for (E*21E'n1EMM)
F
docuent.#riteln(!TiVTEV)1
I
I
for (i*21i'n1iMM)
F
for (E*21E'n1EMM)
F
cTiVTEV*aTiVTEVM!TiVTEV1
I
I
docuent.#riteln(+'!r(The addition of atrices is"+)1
for (i*21i'n1iMM)
F
for (E*21E'n1EMM)
F
docuent.#riteln(cTiVTEV)1
I
I
L/
Web Technologies & Compiler Design Lab Record
')script(
')head(
')htl(
OUTPUT





L;
Web Technologies & Compiler Design Lab Record





LL
Web Technologies & Compiler Design Lab Record


The eleents of >st Matri, are " 1 1 1 1
The eleents of >>nd Matri, are " 1 1 1 1
The addition of atrices is " - - - -
LO
Web Technologies & Compiler Design Lab Record
AIM : Krite A 7rogra for Bu!!le 6ort.
PRO9RAM
'htl(
'head(
'title(Bu!!le 6ort')title(
'script language*+Pava6cript+(
var a*T4:.:-:O:1:LV
var t:n*/1
for( var i*21i'n1iMM)
F
for(var E*21E'nQ11EMM)
F
if(aTEV(aTEM1V)
F
t*aTEV1
aTEV*aTEM1V1
aTEM1V*t1
I
I
I
docuent.#rite(+'h1(The sorted order is"0n!sp1+)1
for(i*21i'n1iMM)
F
docuent.#rite(aTiV)1
docuent.#rite(+0n!sp10n!sp1+)1
I
')script(
')head(
'!ody topargin*.2 leftargin*122(')!ody(
')htl(
OUTPUT
The sorted order is " 1 - 4 . L O
AIM : Krite A 7rogra for ipleentation of Linear 6earch .
O2
Web Technologies & Compiler Design Lab Record
PRO9RAM
'htl(
'head(
'title(Array Addition')title(
'script language*+Eavascript+(
var flag*2:a:n:key:i
var a*ne# Array(12)1
n*parse>nt(#indo#.propt(+?nter the si$e of the array+:++))1
#indo#.alert(+?nter the eleents in the array+)1
for (i*21i'n1iMM)
F
aTiV*parse>nt(#indo#.propt(+?nter the eleent +:++))1
I
key*parse>nt(#indo#.propt(+?nter the searching eleent+:++))1
for (i*21i'n1iMM)
F
if (aTiV**key)
F
flag*11
#indo#.alert(+ eleent is found at location +M(iM1))1
I
I
if (flag**2)
#indo#.alert(+ eleent is not
found+)1))docuent.#riteln(+The eleent is not found+)1
')script(
')head(
'!ody !gcolor*+pink+(
')!ody(
')htl(
O1
Web Technologies & Compiler Design Lab Record
OUTPUT




O-
Web Technologies & Compiler Design Lab Record



O4
Web Technologies & Compiler Design Lab Record
AIM : Krite A 7rogra for displaying an iage on ouse click.
PRO9RAM
'htl(
'head(
'title(onclick iage')title(
')head(
'!ody leftargin*122 topargin*122 !gcolor*+X111111+(
'ig nae*+iages+ #idth*-22 height*-22 src*1.gif +('p(
'for('h4(
'input type*+!utton+ value*+iage1+ on8lick*+docuent.iages.src*_1.gif_ +(
'input type*+!utton+ value*+iage-+
on8lick*+docuent.iages.src*_-.gif_ +(
'input type*+!utton+ value*+iage4+ on8lick*+docuent.iages.src*_4.gif_ +(
')for(')h4(')!ody(')htl(
O5
Web Technologies & Compiler Design Lab Record
OUTPUT


O.
Web Technologies & Compiler Design Lab Record
AIM : Krite A 7rogra 8ode To ?,hi!it Blending ?ffect.
PRO9RAM
'htl(
'head(
'title( P 6cript ')title(
'script language*+Eavascript+(
function !lendOut()
F
))te,t>nput.filters(+!lendTrans+).apply()1
))te,t>nput.style.visi!ility*+hidden+1
te,t>nput.filters(+!lendTrans+).play()1
I
')script(
')head(
'!ody(
'div id*+te,t>nput+ onouseover*+!lendOut()+ style*+#idth"1221
filter"!lendTrans(duration*.)+(
'h1( M&LT> M?D>A ')h1(
')div(
')!ody(
')htl(
O/
Web Technologies & Compiler Design Lab Record
OUTPUT


O;
Web Technologies & Compiler Design Lab Record
Compiler Design
AIM: Wrie a program o $ind 2heher a gi3en sring is ideni$ier or no#
Ideni$iers 2ill be ha3ing he $ollo2ing con3enions
Alphabe 2ill be $ollo2ed b% n*merical or alphabes
In3alid: saring 2ih n*merical
Xinclude'stdio.h(
Xinclude'conio.h(
int isidentifier(char Z)1
int second(char Z)1
int third()1
ain()
F
char strT12V1
int i* Q1 1
printf(+Un enter the desired string+)1
do
F
MMi1
strTiV * getch()1
if(strTiVN*1200strTiVN*14)
printf(+3c+:strTiV)1
if(strTiV**_U!_)
F
QQi1
printf(+U!+)1
I
I#hile(strTiVN*1200strTiVN*14)1
if(isidentifier(str))
F printf(+Uninput string is 3s+:str)1
printf(+Un the given string is an identifier+)1
I
else
Fprintf(+Uninput string is 3s+:str)1
printf(+Un the given string is not identifier+)1
I
getch()1
I
int isidentifier(char Zstr)
F printf(+Uninput string first character is 3c+:strT2V)1
if((strT2V(*_a_00 strT2V'*_$_)HH(strT2V(*_A_00strT2V'*_b_))
F
return(second(strM1))1
I
OL
Web Technologies & Compiler Design Lab Record
else
return 21
I
int second(char Zstr)
F
if((strT2V(* _2_00strT2V'* _O_)HH(strT2V (*_a_ 00strT2V'*_$_)HH(strT2V (* _A_ 00strT2V '*_b_))
F
return(second(strM1))1
I
else
F
if(strT2V ** 12 HHstrT2V ** 14)
F
return(third())1
I
else
F
return 21
I
I
I
int third()
F
return 11
I
OUTPUT:
OO
Web Technologies & Compiler Design Lab Record


AIM: Wrie a program o chec" 2heher he gi3en program conains commens.
Xinclude'stdio.h(
Xinclude'conio.h(
Xinclude'string.h(
122
Web Technologies & Compiler Design Lab Record
ain()
F
int notv*2:count*2:co*2:valid*2:E*2:i:n1
char chT-2V1
printf(+enter the coents"Ut+)1
#hile((chTEV*getchar())N*_Un_)
EMM1
n*strlen(ch)1
for(i*21i'*n1iMM)
F
E*iM11
if(chTiV**_)_00chTEV**_Z_)
F
co*11
I
if(co**100chTiV**_Z_00chTEV**_)_)
F
valid*11
countMM1
I
I
if(co**2)
printf(+no coents+)1
else
F
if(valid**1)
F
printf(+valid coents Un+)1
printf(+no of coents 3d+:count)1
I
else
F
printf(+invalid coents+)1

I
I
getch()1
I
OUTPUT :

121
Web Technologies & Compiler Design Lab Record


AIM: Wrie a c program o con$ig*re a C.9 2hich 2ill accep he *ser inp* sring
$ollo2ing he gi3en C.9#
' >? a!b@ccA
A >? b@c
12-
Web Technologies & Compiler Design Lab Record
! >? a@b
Xinclude'stdio.h(
Xinclude'conio.h(
int i*21
char sT12V1
void 6()1
void A()1
void B()1
void disp()1
void error()1
void ain()
F
clrscr()1
printf(+Biven graar is Un+)1
printf(+6 Q( aB!)ccAUn+)1
printf(+A Q( !)cUn+)1
printf(+B Q( a)!Un+)1
printf(+?nter the stringUn+)1
scanf(+3s+:0s)1
6()1
if(sTiV**=&LL)
printf(+string is validUn+)1
else
printf(+string is invalidUn+)1
getch()1
I
void 6()
F
if(sTiV**_a_)
F
iMM1
B()1
if(sTiV**_!_)
iMM1
else
error()
I
else if(sTiV**_c_)
F
iMM1
if(sTiV**_c_)
F
iMM1
A()1
I
else
error()1
I
124
Web Technologies & Compiler Design Lab Record
I
void A()
F
if(sTiV**_!_HHsTiV**_c_)
iMM1
else
error()1
I
void B()
F
if(sTiV**_a_HHsTiV**_!_)
iMM1
else
error()1
I
void error()
F
printf(+string is invalidUn+)1
getch()1
e,it(2)1
I
OUTPUT :
125
Web Technologies & Compiler Design Lab Record



AIM: Wrie a C program o co*n he n*mber o$ lines & spaces in a inp* sring#
12.
Web Technologies & Compiler Design Lab Record
Xinclude'stdio.h(
Xinclude'conio.h(
Xinclude'string.h(
ain()
F
char strT122V:ch1
int a*2:space* 2:ne#line * 11

printf(+Un enter the stringUn+)1
ch *getche()1
#hile((chN*-;)00(a'1O))
F
strTaV *ch1
if(strTaV **_ _)
spaceMM1
if(strTaV**14)
F
ne#lineMM1
printf(+Un+)1
I
aMM1
ch * getche()1
I
printf(+Un the nu!er of lines usedis * 3d+:ne#line)1
printf(+Un the nu!er of space used is * 3d+:space)1
getch()1
I
OUTPUT:
12/
Web Technologies & Compiler Design Lab Record

AIM: Wrie a C program 2hich 2ill accep he *ser inp* and classi$% hem eiher
as a ineger or as a $loaing poin#
Xinclude'stdio.h(
Xinclude'conio.h(
12;
Web Technologies & Compiler Design Lab Record
Xinclude'string.h(
char inputT12V1
int ,: y: $:a: val1: val-: fl1: fl-1
int dec: decloc: invfp:floatlit1
int inttep: integer: op1
ain()
F
integer * 21
floatlit * 21
fl1*21
fl-*21
val1*21
val-*21
dec*21
decloc*21
invfp*21
inttep*21
op*21
printf(+>nput" +)1
gets(input)1
)Z Cor Cloating Literals Z)
for (,*21 ,'*strlen(input)1 ,MM)
F
if (inputT,V**_._)
F
dec*decM11
decloc*,1
I
I
if (dec**1)
F
for (y*21 y'decloc1 yMM)
F
if ((inputTyV**_2_ HH inputTyV**_1_ HH inputTyV**_-_ HH inputTyV**_4_ HH inputTyV**_5_ HH
inputTyV**_._ HH inputTyV**_/_ HH inputTyV**_;_ HH inputTyV**_L_ HH inputTyV**_O_ HH inputTyV**_._))
val1*val1M11
I
for ($*declocM11 $'*strlen(input)1 $MM)
F
if ((inputT$V**_2_ HH inputT$V**_1_ HH inputT$V**_-_ HH inputT$V**_4_ HH inputT$V**_5_ HH
inputT$V**_._ HH inputT$V**_/_ HH inputT$V**_;_ HH inputT$V**_L_ HH inputT$V**_O_))
val-*val-M11
I
I
else
if (dec(*-)
invfp*11
if (val1**decloc)
F
fl1*11
I
12L
Web Technologies & Compiler Design Lab Record
if (val-**(strlen(input)Qdecloc)Q1)
F
fl-*11
I
)Z ?nd Z)
)Z Cor >nteger Z)
for (a*21 a'*strlen(input)1 aMM)
F
if ((inputTaV**_2_ HH inputTaV**_1_ HH inputTaV**_-_ HH inputTaV**_4_ HH inputTaV**_5_ HH
inputTaV**_._ HH inputTaV**_/_ HH inputTaV**_;_ HH inputTaV**_L_ HH inputTaV**_O_))
F
inttep*inttepM11
I
I
)Z ?nd Z)
if ((fl1**1 00 fl-**1 00 decN*2))
F
floatlit*11
I
if (floatlit**1)
printf(+Cloating Literal+)1
if ((inttep**strlen(input) 00 strlen(input)N*2))
F
integer*11
printf(+>nteger Literal+)1
I
else

if ((floatlit**2 00 integer**2 ))
F
if (invfp**2 00 inputT2VN*2)
printf(+>=JAL>D+)1
else if ((invfp**2 00 inputT2V**2))
printf(+7lease ?nter a JalueN+)1
else if (invfp**1)
printf(+>nvalid Cloating 7oint Literal+)1
I
getch()1
I
OUTPUT:
12O
Web Technologies & Compiler Design Lab Record



AIM: Wrie a program o recogniAe "e%2ords
Xinclude'stdio.h(
112
Web Technologies & Compiler Design Lab Record
Xinclude'conio.h(
Xinclude'string.h(
Xdefine found 1
Xdefine notfound 2
ain()
F
int i:E:flag*notfound:result1
char key#ordsT12VT12V* F+void+:+if+:+else+:+for+:+#hile+:+s#itch+I1
char strT12V1
printf(+Un enter the string+)1
scanf(+3s+:str)1
gets(str)1
printf(+Un string is 3s+:str)1
for(i *21i'/1iMM)
F
printf(+ Un key#ord is 3s+: key#ordsTiV)1
result* strcp(0key#ordsTiVT2V:str)1
printf(+ Ut result is 3d+:result)1
if(result**2)
F
flag * found1
printf(+Unflag is 3d+:flag)1
!reak1
I
I
if(flag ** notfound)
printf(+UnUn string is not a key#ord+)1
else
printf(+UnUn string is key#ord+)1
getch()1
I
OUTPUT :
111
Web Technologies & Compiler Design Lab Record


11-

Das könnte Ihnen auch gefallen