+ All Categories
Home > Documents > Wad Final Doc Print

Wad Final Doc Print

Date post: 13-Apr-2018
Category:
Upload: kiran-kumar
View: 236 times
Download: 0 times
Share this document with a friend
51
1. De ve lo p stat ic page s of an onli ne Book Store by only us in g HTML (the page s sh ou ld reseble!""".aa#on.co$. The "ebsite should consist the follo"ing pages. a. Hoe %age b. &e gistration and 'ser Login c. Books at alo g Hoe%age.htl Hoe page Main.htl! <html> <head> <title> Amazon</title> </head> <body bgcolor="cyan"> <center> <strong><h1>Welcome to AMAZON</h1></strong> <form method="ost" action="login!html" target=blan# > <h$>for boo#s</h$><in%t tye="s%bmit" &al%e="clic# here"> </form> </center> </body> </html> &egistration and user Login &egistration.htl <html> <head> <title> form</title> </head> <body bgcolor=bl%e te't=(hite> <h1 align=center>creat yo%r email id </h1> <mar)%ee><h*>this is google (eb age </h*></mar)%ee> <re> <form> <b> <h+> first name <in%t tye="te't"></in%t><br> second name <in%t tye="te't"></in%t><br> email id <in%t tye="te't"></in%t><br>  ass(ord<in%t tye="ass(ord"><br> conform ass(ord <in%t tye="ass(ord"><br> gender <in%t tye="radio"name="radio" &al%e="radio">female</in%t>  <in%t tye="radio"name="radio" &al%e="radio">male</in%t> dateofbirth <br>  Y .Kiran Kumar P age 1
Transcript
Page 1: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 1/51

1. Develop static pages of an online Book Store by only using HTML (the pages should

reseble!""".aa#on.co$. The "ebsite should consist the follo"ing pages.

a. Hoe %age

b. &egistration and 'ser Login

c. Books atalog

Hoe%age.htl

Hoe pageMain.htl!

<html><head>

<title>

Amazon</title></head>

<body bgcolor="cyan"> <center>

<strong><h1>Welcome to AMAZON</h1></strong><form method="ost" action="login!html" target=blan# >

<h$>for boo#s</h$><in%t tye="s%bmit" &al%e="clic# here">

</form>

</center></body>

</html>

&egistration and user Login

&egistration.htl

<html>

<head><title> form</title>

</head>

<body bgcolor=bl%e te't=(hite><h1 align=center>creat yo%r email id </h1>

<mar)%ee><h*>this is google (eb age </h*></mar)%ee>

<re>

<form><b>

<h+>

first name <in%t tye="te't"></in%t><br>second name <in%t tye="te't"></in%t><br>

email id <in%t tye="te't"></in%t><br>

 ass(ord<in%t tye="ass(ord"><br>conform ass(ord <in%t tye="ass(ord"><br>

gender <in%t tye="radio"name="radio"

&al%e="radio">female</in%t>

  <in%t tye="radio"name="radio"&al%e="radio">male</in%t>

dateofbirth <br>

 Y.Kiran Kumar Page 1

Page 2: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 2/51

  day<in%t tye="date"size="*"

></in%t>month<select name=month><otion>,an

<otion>feb

<otion>mar <otin>ar 

<otion>may

<otion>,%ne

  <otion>,%ly<oiton>a%g

<otion>se

<otion>oct<otion>no&

<otion>dec

</select></in%t>year<select name=year>

<otion>1-.

<otion>1-.0<otion>i-..

</select></in%t>

select yo%r co%ntry<select name =co%ntry>

<otion> %sa

<otion> india

<otion> africa</select><br>

area of interrest <br><br>

entertainment<in%t tye="chec# bo'" &al%e ="c1"></in%t>

games <in%t tye="chec# bo'" &al%e="c*"></in%t>select yo%r )%setion<select name=)%estion>

  <otion>(hat is yo%r et name2

  <otion>(hat is yo%r fa&orite food 2  <otion>(hat is yo%r aim2

</select><br>ans(er <in%t tye="te't"><br>

comment

  <te't area></te't area><br>

 <in%t tye="reset" name ="reset" &al%e ="reset"></in%t> <in%t tye="s%bmit" name="s%bmit" &al%e="s%bmit"></in%t>

</h+></in%t>

</b>

</form></body>

</html>

 Y.Kiran Kumar Page *

Page 3: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 3/51

)utput!

Login.htl!

<html><head>

<title>login age</title>

</head>

<body bgcolor="cyan"> <center><strong><h1> AMAZON </h1></strong></center>

<right>

<table align="right"><tr>

<td><h$>%ser name</td>

<td><in%t tye="te't" ></td>

<td></td></tr>

<tr>

<td><h$>ass(ord</td><td><in%t tye="ass(ord"></td>

<td></td>

</tr>

 Y.Kiran Kumar Page +

Page 4: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 4/51

<tr>

<td><form method="ost" action="catalog!html" >

<in%t tye="s%bmit" &al%e="s%bmit" >

</form></td>

<td>

<form method="ost" action="%serro!html" >

<in%t tye="s%bmit" &al%e="register" >3nbs43nbs4

<in%t tye="reset" &al%e="reset"></form></td>

</tr></table>

</body>

</html>

Books catalog

atalog.htl!

<html><head><title>

 boo#s catalog</title>

</head><body bgcolor="cyan">

<center><h1>AMAZON</h1></center>

<form method="ost" action="shoing!html"><left>

<table>

<tr>

<td><b><h+>frontend boo#s</td><td></td></tr>

<tr>

<td></td><td><h$>536s</td>

</tr>

<tr><td></td>

<td><h$>Ads</td>

</tr><tr>

<td></td><td><h$>7A8A

</td></tr><tr>

<td><b><h+>bac#end boo#s</td>

<td></td></tr>

<tr>

 Y.Kiran Kumar Page $

Page 5: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 5/51

<td></td>

<td><h$>Oracle</td></tr>

<tr>

<td></td><td><h$>Ms 9:; 9er&er 

</td></tr>

<tr>

<td></td><td><h$>My9)l </td>

</tr>

</table></h$>

<center>

<b>for b%y one of these boo#s<br>

</b><in%t tye="s%bmit" &al%e="clic# here">

</center></form></body>

</html>

Main.htl!

 Y.Kiran Kumar Page

Page 6: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 6/51

Login.htl!

atalog.htl!

*. Design and develop a +eedback for using ,avaScript.

<html>

<head>

<title>feed bac# form</title>

 Y.Kiran Kumar Page

Page 7: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 7/51

<scrit tye="te't/,a&ascrit">N5?@ON 5A;95OBCD

E

  &ar 95OB=F4@Cdoc%ment!feedbac#!)1GFH!5IB5JB6D

95OB=95OBK4

@Cdoc%ment!feedbac#!)1GFH!5IB5JB6D

95OB=95OBK4@Cdoc%ment!feedbac#!)1G1H!5IB5JB6D

95OB=95OBK+4

@Cdoc%ment!feedbac#!)1G*H!5IB5JB6D95OB=95OBK*4

@Cdoc%ment!feedbac#!)1G+H!5IB5JB6D

95OB=95OBK14@Cdoc%ment!feedbac#!)*GFH!5IB5JB6D

95OB=95OBK4

@Cdoc%ment!feedbac#!)*G1H!5IB5JB6D95OB=95OBK+4

@Cdoc%ment!feedbac#!)*G*H!5IB5JB6D

95OB=95OBK*4

@Cdoc%ment!feedbac#!)*G+H!5IB5JB6D95OB=95OBK14

@Cdoc%ment!feedbac#!)+GFH!5IB5JB6D

95OB=95OBK4@Cdoc%ment!feedbac#!)+G1H!5IB5JB6D

95OB=95OBK+4

@Cdoc%ment!feedbac#!)+G*H!5IB5JB6D

95OB=95OBK*4@Cdoc%ment!feedbac#!)+G+H!5IB5JB6D

95OB=95OBK14

@Cdoc%ment!feedbac#!)$GFH!5IB5JB6D95OB=95OBK4

@Cdoc%ment!feedbac#!)$G1H!5IB5JB6D

95OB=95OBK+4@Cdoc%ment!feedbac#!)$G*H!5IB5JB6D

95OB=95OBK*4

@Cdoc%ment!feedbac#!)$G+H!5IB5JB6D95OB=95OBK14

@Cdoc%ment!feedbac#!)GFH!5IB5JB6D95OB=95OBK4

@Cdoc%ment!feedbac#!)G1H!5IB5JB6D95OB=95OBK+4

@Cdoc%ment!feedbac#!)G*H!5IB5JB6D

95OB=95OBK*4@Cdoc%ment!feedbac#!)G+H!5IB5JB6D

95OB=95OBK14

 Y.Kiran Kumar Page 0

Page 8: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 8/51

(indo(!alertC"totalscore" K95OBD4

L</scrit>

</head>

<body><h1>< style ="color 4in#4margin*F'">

<center>feed bac# form</center>

</>

</h1>

<form name="feedbac#" ons%bmit="5A;95OBCD">

lect%re name<in%t tye=te't name=n* size=1F &al%e=" "><br>s%b,ect<in%t tye=te't name=n* size=1F &al%e=" "><br>

1!comm%nication s#ills<br><in%t tye=radio name=)1>e'celent

<in%t tye=radio name=)1>&ery good

<in%t tye=radio name=)1>good<in%t tye=radio name=)1>a&erage<br><br>

*!s%b,ect #no(ledge<br>

<in%t tye=radio name=)*>e'celent

<in%t tye=radio name=)*>&ery good<in%t tye=radio name=)*>good

<in%t tye=radio name=)*>a&erage<br><br>

+!clarification of do%bts!<br><in%t tye=radio name=)+>e'celent

<in%t tye=radio name=)+>&ery good

<in%t tye=radio name=)+>good

<in%t tye=radio name=)+>a&erage<br><br>$!other #no(ledge!<br>

<in%t tye=radio name=)$>e'celent

<in%t tye=radio name=)$>&ery good<in%t tye=radio name=)$>good

<in%t tye=radio name=)$>a&erage<br><br>

!o&erall grading<br><in%t tye=radio name=)>e'celent

<in%t tye=radio name=)>&ery good

<in%t tye=radio name=)>good<in%t tye=radio name=)>a&erage

<in%t tye=b%tton name="s%bmit" &al%e="s%bmit" onclic#=calscoreCD>

</form></body>

</html>

 Y.Kiran Kumar Page .

Page 9: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 9/51

)ut%ut!

-. alidate the &egistration and 'ser Login pages of progra / 1.

Hoe page!

Main.htl!

<html>

<frameset ro(s="*">

<frame src="to!html" name="to" scrolling ="no" frameborder ="F"><frameset cols="*0">

<frame src="left!html" name="left" scrolling ="no" frameborder ="F">

<frame src="right!html" name="right" scrolling ="a%to" frameborder ="F"></frameset>

</frameset>

</html>

Top.htl!

<html>

<body bgcolor="in#"><br><br>

<mar)%ee><h1 align=PcenterP><b><%>ON;@NB QOOJ 

9?OARB</%></b></h1></mar)%ee>

 Y.Kiran Kumar Page -

Page 10: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 10/51

</body>

</html>

&ight.htl!

<html><body>

<br><br><br><br><br>

<h* align="center">

<b><> (elcome to online boo# storage! Sress login if yo% areha&ing id other(ise ress registration!

</></b></h*>

</body> </html>

Left.htl!

<html>

<body bgcolor="in#"><h+>

<%l>

<li><a href="login!html" target="right"><font color="blac#">;OR@N</font></a></li><br><br><li><a href="rofile!html" target="right"><font color="blac#">

9B SO@;B</font></a></li><br><br>

<li><a href="catalog!html" target="right"><font color="blac#">QOOJ9 5A?A;OR</font></a></li><br><br>

<li><a href="scart!html" target="right"><font color="blac#">

9IOSS@NR5A?</font></a></li><br><br><li><a href="ayment!html" target="right"><font color="blac#">

SATMBN?</font></a></li><br><br>

<br><br>

</%l></body>

</html>

&egistration and user Login

Login.htl!

<html>

<body bgcolor="in#"><br><br><br><scrit lang%age=",a&ascrit">

f%nction &alidateCD

E&ar flag=14

ifCdoc%ment!myform!id!&al%e==""UUdoc%ment!myform!(d!&al%e==""D

E alertC";ogin@d and Sass(ord m%st be filled"Dflag=F4

Li

fCflag==1DE alertC"8A;@6 @NS?"D4

(indo(!oenC"catalog!html""right"D4

 Y.Kiran Kumar Page 1F

Page 11: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 11/51

L else

E alertC"@N8A;@6 @NS?"D4//doc%ment!myform!foc%sCD4

LL

</scrit><form name="myform">

<di& align="center"><re>

;OR@N @6<in%t tye="te't" name="id"><br>

SA99WO6<in%t tye="ass(ord" name="(d"><br><br></re>

<in%t tye="b%tton" &al%e="o#" on5lic#="&alidateCD">3nbs43nbs43nbs43nbs4

<in%t tye="reset" &al%e="clear" ></di&>

</form>

</body></html>

atalog.htl!<html><body bgcolor="in#"><br><br><br>

<scrit lang%age=",a&ascrit">

f%nction &alidateCDE

&ar flag=14

ifCdoc%ment!myform!id!&al%e==""UUdoc%ment!myform!title!&al%e==""UU

doc%ment!myform!no!&al%e==""UU

doc%ment!myform!cost!&al%e==""D

Eflag=F4

L

str=doc%ment!myform!title!&al%e4&ar str1=doc%ment!myform!cost!&al%e4

ifCVCCstr=="c"33 str1==$$$D UU Cstr==",s" 33 str1==DDD

Eflag=F4

L

</di&><br><br>

<di& align="center"><in%t tye="s%bmit" &al%e="o#" on5lic#="&alidateCD"> 3nbs43nbs43nbs43nbs4

<in%t tye="reset" &al%e="clear"></form>

</body>

</html>ifCflag==1D

E

 Y.Kiran Kumar Page 11

Page 12: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 12/51

alertC"8A;@6 @NS?"D4

Lelse

E

alertC"@N8A;@6 @NS?"D4doc%ment!myform!foc%sCD4

L

L

</scrit><form name="myform" action="scart!html" target="right">

<di& align="center"><re>

;OR@N @6 <in%t tye="te't" name="id"><br>?@?;B <in%t tye="te't" name="title"><br>

 NO!O QOOJ9 <in%t tye="te't" name="no"><br>

5O9? O QOOJ <in%t tye="te't"name="cost"><br></re><br><br>

)'T%'T!

Main.htl

Login.htl!

 Y.Kiran Kumar Page 1*

Page 13: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 13/51

atalog.htl!

0. reate a "eb page "ith all types of ascading style sheets.

y#.css

h+Efontfamilyarial4fontsize*F4colorbl%eLtableEbordercolorredL

tdEfontsize*Ft4colorgreenL

allstylesheets.htl

 Y.Kiran Kumar Page 1+

Page 14: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 14/51

<html>

<head><h1><center><Q><>A;; 9?T;B 9IBB?</></Q></center></h1>

<title>%se of internal and e'ternal style sheet</title>

<lin# rel="stylesheet" href="'yz!css" tye="te't/css"><style tye="te't/css">

!&idEfontfamilyQohamos4fontstyleitalic4colorred4te'taligncenter4L

!aniEfontfamily&ardana4fontstylebold4fontsize*F4te'taligncenter4L

fontEfontfamilygeorgia4colorbl%e4fontsize*FL%lEliststyletyecircleL

</style>

</head><body>

<ol style="liststyletyelo(eralha">

<b><%>9BB 8@6TAN@JB?IAN ROS O 5O;;BRB9</%></b><br><br><br><li>sree &idyani#ethan eng college</li>

<li>sree &idyani#ethan degree college</li>

<li>sree &idyani#ethan instit%te of management</li><li>sree &idyani#ethan college of n%rsing</li><li>sree &idyani#ethan college of harmacy</li>

</ol>

< style="fontsize*Ft4colorgreen"><mar)%ee>

9BB 8@6TAN@JB?IAN ROS O 5O;;BRB9</mar)%ee>

</>< class="ani">sree &idyani#ethan gro% of college o(ned by M!Mohan bab%<br>it is

aro&ed by A@5?B!@t is affliated to ,nt%aanantha%r</><br><br>

<h* class="&id">sree &idyani#ethan eng college</h*><br>

<font>sree &idyani#ethan engineering clg conferred (ith A%tonomo%s by the Rc</font><br><br>

<font>

<h*>list of co%rces offered</h*><%l>

<li>M5A</li>

<li>59B</li><li>M!?ech</li>

<li>59B</li>

<li>@?@</li><li>BBB</li>

<li>MB5IAN@5A;</li></%l>

</font><h+>es%lts of M5A st%dents</h+>

<table (idth="1FF" cellsacing="*" celladding="*"border="">

<tr><th>s!name</th>

<th>mar#s</th>

 Y.Kiran Kumar Page 1$

Page 15: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 15/51

<th>res%lt</th>

</tr><tr>

<td align="center">#!g%r%</td>

<td align="center">.</td><td align="center">ass</td>

</tr>

<tr>

<td align="center">#!g%r%</td><td align="center">.</td>

<td align="center">ass</td>

</tr><tr>

<td align="center">#!g%r%</td>

<td align="center">.</td><td align="center">ass</td>

</tr>

</table></body></html>

2. reate and save an 3ML docuent at the server4 "hich contains 15 users inforation. 6rite a

progra4 "hich takes 'ser 7d as an input and returns the user details by taking the user

inforation fro the 3ML docuent.

 Y.Kiran Kumar Page 1

Page 16: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 16/51

9te1 set the classath for 'erces@ml!,ar4

set classath=6XAache Rro%X?omcat $!1XcommonXendorsedX'erces@ml!,ar4

ste * Bdit yo%r 'ser7nfo.8ava  rogram %sing any editor 

ste $ create an StudentData.l file (ith fe( records

ste + 5omile the ,a&a rogram

ste $ r%n the ,a&a rogram (ith command line arg%ments C filename idD

d!96:D;8ava 'ser7nfo  StudentData.xml   1

9o%rce 5ode

imort ,a&a'!'ml!arsers!9AYSarseractory4

imort ,a&a'!'ml!arsers!9AYSarser4imort org!'ml!sa'!4imort org!'ml!sa'!helers!4

class ser@nfo e'tends 6efa%ltIandler 

E ri&ate 9tring id&al%e=""4

 ri&ate static 9tring a=""4

 ri&ate boolean isid4 ri&ate 9tringQ%ffer &al%e=ne( 9tringQ%fferCD4

 ri&ate 9tring streleGH=E"%name""%address""%dob"L4

 %blic static &oid mainC9tringGH argsDthro(s B'cetionE

ser@nfo %i=ne( ser@nfoCD4

a=argsG1H4%i!readCargsGFHD4

L

 %blic &oid readC9tring filenameDthro(s B'cetion

E

YM;eaderreader=YM;eaderactory!createYM;eaderC"org!aache!'erces!arsers!9AYSarser"D4

reader!set5ontentIandlerCthisD4reader!arseCfilenameD4

L

 %blic &oid start6oc%mentCDthro(s 9AYB'cetion

E9ystem!o%t!rintlnC"6oc%ment has started"D4

L

 Y.Kiran Kumar Page 1

Page 17: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 17/51

 %blic &oid startBlementC9tring %ri 9tring localName9tring gName Attrib%tes attsDthro(s

9AYB'cetionE

ifClocalName!e)%alsC"%ser"DD

Eid&al%e=atts!get8al%eC"id"D4

L

else ifCid&al%e!e)%alsCaDD

EforCint i=F4i<strele!length4iKKD

E

ifClocalName!e)%alsCstreleGiHDDE

&al%e!set;engthCFD4

isid=tr%e4L

L

Lelse

isid=false4

L

 %blic &oid charactersCcharGH chint startint lenDthro(s 9AYB'cetionE

ifCisidD

E&al%e!aendCchstartlenD4

L

L

 %blic &oid endBlementC9tring %ri 9tring localName9tring gNameDthro(s 9AYB'cetionE

ifCisid33VClocalName!e)%alsC"%ser"DDD

E9ystem!o%t!rintlnC&al%e!to9tringCDD4

L

&al%e!set;engthCFD4L

 %blic &oid end6oc%mentCDthro(s 9AYB'cetionE

9ystem!o%t!rintlnC"6oc%ment has ended"D4L

L

 Y.Kiran Kumar Page 10

Page 18: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 18/51

 StudentData.xml

<2'ml &ersion="1!F" encoding="?."2>

<%ser@nfo>

<%ser id="1">

<%name>amesh</%name>

<%address>Qangalore</%address>

<%dob>1*</%dob></%ser>

<%ser id="*"><%name>Shani</%name>

<%address>Iyderabad</%address>

<%dob>1+</%dob></%ser>

<%ser id="+"><%name>M%ni</%name>

<%address>5hennai</%address>

<%dob>1$</%dob>

</%ser>

</%ser@nfo>

 Y.Kiran Kumar Page 1.

Page 19: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 19/51

<. %rogras using 3ML Schea 4 3SLT=3SL ( Bookcatalog.l$

<2'ml &ersion="1!F"2>

<2'mlstylesheet tye="te't/'sl" href="boo#catalog!'sl"2>

<catalog>

<boo#> <title>9oft(are Bngineering</title><a%thor>Sressman</a%thor>

<co%ntry>9A</co%ntry>

<%blication>SI@</%blication>

<rice>+F</rice>

<year>*FF1</year>

</boo#>

<boo#>

<title>5om%ter Net(or#s</title>

<a%thor>?enanba%m</a%thor>

<co%ntry>9A</co%ntry>

<%blication>SI@</%blication>

<rice>$FF</rice>

<year>1--.</year>

</boo#>

<boo#>

<title>6atabase Management 9ystem</title>

<a%thor>ama#rishna</a%thor><co%ntry>@ndia</co%ntry>

<%blication>SI@</%blication>

<rice>$F</rice>

<year>*FFF</year>

</boo#>

<boo#>

<title>Web ?echnology</title>

<a%thor>5oyal</a%thor>

<co%ntry>9A</co%ntry>

<%blication>SI@</%blication>

<rice>$0F</rice>

<year>*FF$</year>

</boo#>

</catalog>

 Y.Kiran Kumar Page 1-

Page 20: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 20/51

bookcatalog.sl

<2'ml &ersion="1!F"2>

<'slstylesheet &ersion="1!F"

'mlns'sl="htt//(((!(+!org/1---/Y9;/?ransform">

<'sltemlate match="/"><html>

<body>

<h*>My Qoo# 5ollection</h*>

<table border="1">

<tr bgcolor="-acd+*">

<th>title</th>

<th>a%thor</th>

<th>co%ntry</th>

<th>%blication</th>

<th>rice</th>

[ <th>year</th>

</tr>

<'slforeach select="catalog/boo#">

<tr>

<td><'sl&al%eof select="title"/></td>

<td><'sl&al%eof select="a%thor"/></td>

<td><'sl&al%eof select="co%ntry"/></td><td><'sl&al%eof select="%blication"/></td>

<td><'sl&al%eof select="rice"/></td>

<td><'sl&al%eof select="year"/></td>

</tr>

</'slforeach>

</table>

</body>

</html>

</'sltemlate>

</'slstylesheet>

 Y.Kiran Kumar Page *F

Page 21: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 21/51

)utput!

>. %rogra using D)M = S:3.

Do%arserBookStore.8ava

imort ,a&a!io!ile4imort ,a&a'!'ml!arsers!6oc%mentQ%ilder4

imort ,a&a'!'ml!arsers!6oc%mentQ%ilderactory4

imort org!(+c!dom!6oc%ment4

imort org!(+c!dom!Blement4

imort org!(+c!dom!Node;ist4

/

  se 6OM arser to dislay all boo#sisbntitle and a%thors/

 %blic class 6omSarserQoo#9tore

E

 %blic static &oid mainC9tringGH argsDthro(s B'cetion

E

6oc%mentQ%ilderactory factory=6oc%mentQ%ilderactory!ne(@nstanceCD4

6oc%mentQ%ilder docQ%ilder=factory!ne(6oc%mentQ%ilderCD4

ile file=ne( ileC"boo#store!'ml"D4

6oc%ment doc=docQ%ilder!arseCfileD4

//Ret a ;ist of all elements in the doc%ment

//?he (ild card matches all the tags Node;ist list=doc!getBlementsQy?agNameC""D4

int boo#co%nt=F4

forCint i=F4i<list!get;engthCD4iKKD

E

//Ret the elements boo#Cattrib%te isbnDtitle a%thor 

 Y.Kiran Kumar Page *1

Page 22: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 22/51

Blement element=CBlementDlist!itemCiD4

9tring nodeName=element!getNodeNameCD4

ifCnodeName!e)%alsC"boo#"DD

E

 boo#co%ntKK49ystem!o%t!rintlnC"Qoo#"Kboo#co%ntD4

9tring isbn=element!getAttrib%teC"@9QN"D4

9ystem!o%t!rintlnC"Xt@9QNXt"KisbnD4

L

else ifCnodeName!e)%alsC"title"DD

E

9ystem!o%t!rintlnC"Xt?itleXt"Kelement!get5hildNodesCD!itemCFD!getNode8al%eCDD4

L

else ifCnodeName!e)%alsC"a%thor"DD

E

9ystem!o%t!rintlnC"XtA%thorXt"Kelement!get5hildNodesCD!itemCFD!getNode8al%eCDD4

L

  L

  L L

  )utput!

  ZXWA6>,a&ac 6omSarserQoo#9tore!,a&a

ZXWA6>,a&a 6omSarserQoo#9toreQoo#1

  @9QN F1*+$FF1

  ?itle 7a&arogramming

  A%thor ?an

Qoo#*

  @9QN F1*+$FF*

  ?itle More 7a&a Srogramming

  A%thor 7an Ah ?ech

Qoo#+

  @9QN -0..1+10.+$*

  ?itle Srogramming (ith ,a&a

  A%thor 9%resh#%mar 

  A%thor Bs(ar reddy

A%thor agha&an

 Y.Kiran Kumar Page **

Page 23: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 23/51

S:3%arserBookstore.8ava

imort ,a&a!io!ile4

imort ,a&a'!'ml!arsers!9AYSarser4

imort ,a&a'!'ml!arsers!9AYSarseractory4

imort org!'ml!sa'!Attrib%tes4imort org!'ml!sa'!9AYB'cetions4

imort org!'ml!sa'!helers!6efa%ltIandler4

 %blic class 9AYSarserQoo#store

 E

 ri&ate string c%rrentBlement4

 ri&ate int boo#co%nt=14

 ri&ate 9AYSarserQoo#storeCD

E

try

E

9AYSarser actory factory=9AYSarseractory!ne(@nstanceCD4

9AYSarser sa'Sarser=factory!ne(9AYSarserCD4

9AYSarser!arseCne( ileC"boo#store!'ml"Dne( MyIandlerCDD4

catchCB'cetion eD

E

e!rint9tac#?raceCD4

LL

 %blic static &oid mainC9tring argsGHD

E

ne( 9AYSarserQoo#storeCD4

L

class MyIandler e'tends 6efa%lt Iandler 

E

//callbac# to handle a element start tag

 %blic &oid startBlementC9tring %ri9tring localname9tring )NameAttrib%tes attrib%tesDthro(s

9AYB'cetion

E

c%rrentBlement=)Name4

ifCc%rrentBlement!e)%alsC"boo#"DD

E

 Y.Kiran Kumar Page *+

Page 24: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 24/51

9ystem!o%t!rintlnC"Qoo#"Kboo#co%ntD4

 boo#co%ntKK4

9tring isbn=attrib%tes!get8al%eC"@9QN"D4

9ystem!o%t!rintlnC"Xt @9QNXt"KisbnD4

LL

//call bac# to handle element and tag

 %blic &oid endBlementC9tring %ri9tring localName9tring )NameDthro(s 9AYB'cetion

E

c%rrentBlement=" "4

L

//callbac# to handle the character te't date inside an element

 %blic &oid charactersCcharGH charsint startint lengthDthro(s 9AY B'cetion

E

ifCc%rrentBlement!e)%alsC"title"DD

E

9ystem!o%t!rintlnC"Xt titleXt"KKne(9tringCcharsstartlengthDD4

L

else ifCc%rrentBlement!e)%alsC"a%thor"DD

E

9ystem!o%t!rintlnC"Xt A%thorXt"Kne(9tringCcharsstartlengthDD4

L  LLL

output!

  Qoo#1

  @9QN F1*+$FF1

  title 7a&arogramming

  A%thor ?an

Qoo#*

  @9QN F1*+$FF*

  title More 7a&a Srogramming

  A%thor ?an Ah ?ech

Qoo#+

  @9QN -0..1+10.+$*

  title Srogramming (ith ,a&a

  A%thor Bs(ar reddy

 Y.Kiran Kumar Page *$

Page 25: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 25/51

?. a. 6rite a 8ava progra to get 7% :ddress4 Host @ae and %ort @ubers of a Local syste

imort ,a&a!io!4

imort ,a&a!net!4public class IPTest

E

 %blic static &oid mainC9tring argsGHDthro(s n#no(nIostB'cetionE

@netAddress addr=@netAddress!get;ocalIostCD4

//getting @S Address of localhostgetIostAddress ret%rn @S Address//in te't%al format

9tring iAddress=addr!getIostAddressCD4

9ystem!o%t!rintlnC"@S Address of localhost from ,a&a rogram"KiAddressD4//Nostname

9tring hostname=addr!getIostNameCD4

9ystem!o%t!rintlnC"Name of hostname"KhostnameD4

//ort N%mber 1F*$ to + 10*F

forCint ort=1F*$4ort<=10*F4ortKKDE

tryE

9er&er9oc#et ser&er=ne( 9er&er9oc#etCortD4

LcatchC@OB'cetion eD

E

9ystem!o%t!rintlnC"?here is a ser&er on ort"KortD4L

L

LL

utput!

@S Address of localhost from ,a&a rogram1FF!1FF!1FF!100 Name of hostnames&imlab100

?here is a ser&er on ort1F*

?here is a ser&er on ort1*?here is a ser&er on ort1+

?here is a ser&er on ort1$

?here is a ser&er on ort1

b. 6rite a ,ava %rogra using Datagra ounication.

Dserver.8ava

imort ,a&a!net!4

imort ,a&a!io!4

class 69er&er E

 Y.Kiran Kumar Page *

Page 26: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 26/51

 %blic static &oid mainC9tring argsGHDthro(s @OB'cetion

EQ%fferedeader #ybd=ne( Q%fferedeaderCne( @n%t9treameaderC9ystem!inDD4

@netAddress localadrs=@netAddress!get;ocalIostCD4

@netAddress remoteadrs=n%ll46atagram9oc#et dsoc#et=ne( 6atagram9oc#etC+$D4

int b%ffersize=*FFF4

int remoteort4

6atagramSac#et o%tgram49ystem!o%t!rintlnC"?ye e'it to )%it"D4

 boolean more=tr%e4

(hileCmoreDE

 byteGHinb%ffer=ne( byteGb%ffersizeH4

6atagramSac#et ingram=ne( 6atagramSac#etCinb%fferb%ffersizeD4 byteGHo%tb%ffer=ne( byteGb%ffersizeH4

dsoc#et!recei&eCingramD4

remoteadrs=ingram!getAddressCD4remoteort=ingram!getSortCD49tring data=ne( 9tringCingram!get6ataCDD4

data=data!trimCD4

ifCdata!e)%alsC"e'it"DD brea#4

9ystem!o%t!rintlnC"rom client"KdataD4

9tring rely=#ybd!read;ineCD4o%tb%ffer=rely!getQytesCD4

o%tgram=ne( 6atagramSac#etCo%tb%ffero%tb%ffer!lengthremoteadrsremoteortD4

dsoc#et!sendCo%tgramD4

ifCrely!e)%alsC"e'it"DD brea#4

  L

dsoc#et!closeCD4  L

 L

output!

ZXWA6>,a&ac 69er&er!,a&a

ZXWA6>,a&a 69er&er ?ye e'it to )%it

rom clienthai hello dis is yasas(iniers%ing M5A

 Y.Kiran Kumar Page *

Page 27: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 27/51

Dclient.8ava

imort ,a&a!net!4

imort ,a&a!io!4

class 65lient

E %blic static &oid mainC9tring argsGHDthro(s @OB'cetion

E

Q%fferedeader #ybd=ne( Q%fferedeaderCne( @n%t9treameaderC9ystem!inDD4

@netAddress localadrs=@netAddress!get;ocalIostCD4

@netAddress remoteadrs=localadrs4

6atagram9oc#et dsoc#et=ne( 6atagram9oc#etC+$0D4

int b%ffersize=*FFF4

 byteGH o%tb%ffer=ne( byteGb%ffersizeH4

6atagramSac#et o%tgram4

9ystem!o%t!rintlnC"start the dilog from this client"D4

 boolean more=tr%e4

(hileCmoreD

E

 byteGH inb%ffer=ne( byteGb%ffersizeH4

6atagramSac#et ingram=ne( 6atagramSac#etCinb%fferb%ffersizeD4

9tring send=#ybd!read;ineCD4

o%tb%ffer=send!getQytesCD4o%tgram=ne( 6atagramSac#etCo%tb%ffero%tb%ffer!lengthremoteadrs+$D4

dsoc#et!sendCo%tgramD4

ifCCsend!trimCDD!e)%alsC"e'it"DD

 brea#4

dsoc#et!recei&eCingramD4

9tring data=ne( 9tringCingram!get6ataCDD4

data=data!trimCD4

9ystem!o%t!rintlnC"rom 9er&er"KdataD4

ifCdata!e)%alsC"e'it"DD

 brea#4

  L

dsoc#et!closeCD4

  L

  L

 Y.Kiran Kumar Page *0

Page 28: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 28/51

output!

ZXI?M;>,a&ac 65lient!,a&a

ZXI?M;>,a&a 65lientstart the dilog from this client

hai hello dis is yasas(iniers%ing M5A

A. 6rite a basic Servlet progra that ust display inforation like

a. &euest ethod used by the client and

b. urrent syste date

imort ,a&a'!ser&let!4

imort ,a&a'!ser&let!htt!4imort ,a&a!io!4

 %blic class O%r9r& e'tends Itt9er&letE

 %blic &oid ser&iceCItt9er&lete)%est re)%est Itt9er&letesonse resonseD thro(s

9er&letB'cetion @OB'cetionE

9ystem!o%t!rintlnC" 9tart of 9er&ice CO%r9r&D "D4

SrintWriter o%t = resonse!getWriterCD4

 ,a&a!%til!6ate no( = ne( ,a&a!%til!6ateCD4o%t!rintlnC" "D4

o%t!rintlnCno(D4o%t!rintlnC""D49ystem!o%t!rintlnC" end of ser&iceCO%r9r&D"D4

L

L

7n )rder to copile the Servlets!C

1! coy ser&letai!,ar to the (or#ing directory*! r%n the follo(ing command

dXser&lete'amlesX>set 5;A99SA?I=ser&letai!,ar!

  %ser \,a&ac] command to comile the ser&let class 7a&a9oft has secified astandard roced%re for assembling a (eb alication! ?he roced%re is

a! create a directory to lace the reso%rces of a (eb alication Ceg! 6XO%rWaD! ?his

directory is called as (eb root directory! b! nder (ebroot create a directory (ith name \WBQ@N]

+! nder WBQ@N create the follo(ing t(o directories

a! ;ib > ,ar files m%st be coied %nder this directory

 b! 5lasses > classes m%st be coied %nder this directory!

 Y.Kiran Kumar Page *.

Page 29: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 29/51

$! coy \(eb!'ml] to WBQ@N] directory! Also ro&ided information abo%t the (eb alication!

<(eba><ser&let>

<ser&letname>sone</ser&letname>

<ser&letclass>O%r9r&</ser&letclass></ser&let>

<ser&letmaing>

<ser&letname>sone</ser&letname>

<%rlattern>/done/sr&</%rlattern></ser&letmaing>

</(eba>

 Note (eb!'ml is called deloymentdescritor!! coy the static reso%rces %nder the (ebroot or the s%b directories of the (ebroot! C(e sho%ld not

coy the static reso%rces %nder WBQ@ND!

! coy ser&let classes %nder \WBQ@NXclasses]!

5. enerate a Servlet4 that "ill accept for data fro HTML file "hich includes @ae of the user andfavorite prograing language described in ters of a L7ST4 and it ust display user nae and

language selected by a particular lient.

&euest.htl

<html><head>

<title>e)%est Srocessing</title>

</head><body bgcolor="megenta">

<form name="f" method="ost" action="Xser&let">

%sername<in%t tye="te't" name="%sername"/><br><br>

select yo%r a&arite rogramming lang%age

<select name="1">

<otion &al%e="c">c</otion><otion &al%e="7a&a">7a&a</otion>

<otion &al%e="h">Sh</otion>

<otion &al%e="8Q!Net">8Q!NB?</otion></select>

<br><br>

<in%t tye="s%bmit" &al%e="s%bmit" /></form>

</body>

</html>9

loginServlet.8ava

imort ,a&a!io!4

imort ,a&a'!ser&let!4

imort ,a&a'!ser&let!htt!4

 Y.Kiran Kumar Page *-

Page 30: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 30/51

 %blic class login9er&let e'tends Itt9er&let

E

 %blic &oid doSostCItt9er&lete)%est re)%est Itt9er&letesonse resonseDthro(s

@OB'cetion 9er&letB'cetion

E9tring %sername=re)%est!getSarameterC"%sername"D4

9tring l=re)%est!getSarameterC"l"D4

9ystem!O%t!SrintlnC"%sername"K%sernameD4

9ystem!O%t!SrintlnC"fa&orite l"KlD4

Srint(riter (riter=resonse!getWriterCD4

9tring htmlresonse="<html>"4

htmlresonseK="<h*>yo%r %sername"K%sernameK"<br>"4

htmlresonseK="yo%r fa&orite rogramming lang%age is"KlK"</h*>"4

lang%age is"KlK"</h*>"4

htmlresonseK="</html>"4

(riter!rintlnChtmlresonseD4

L

L

"eb.l

<(eba>

<ser&let>

<ser&letname>s1</ser&letname><ser&letclass>loginser&let</ser&letclass>

</ser&let>

<ser&letmaing>

<ser&letname>s1</ser&letname>

<%rlattern>/ser&let</%rlattern>

</ser&letmaing>

</(eba>

  11. enerate a Servlet page that sho"ing the Session 7D4 reation Tie4 Last :ccessed Tieand Ma 7nactive 7nterval. :long "ith page should display links like &eload this page and 7nvalidate

the Session. 6hen "e press the &eload this page link the above inforation should be redisplayed. 7f 

"e press 7nvalidate the Session link the page "ill display one ore link like create ne" session along

"ith it has to display essage like session invalidated.

 Y.Kiran Kumar Page +F

Page 31: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 31/51

imort ,a&a!io!4

imort ,a&a!%til!4imort ,a&a'!ser&let!4

imort ,a&a'!ser&let!htt!4

 %blic class 9essionB'amle e'tends Itt9er&let E

  %blic &oid doRetCItt9er&lete)%est re)%est Itt9er&letesonse resonseD

  thro(s @OB'cetion 9er&letB'cetion  E

  resonse!set5ontent?yeC"te't/html"D4

  SrintWriter o%t = resonse!getWriterCD4 

Itt9ession session = re)%est!get9essionCtr%eD4

  // rint session info  6ate created = ne( 6ateCsession!get5reation?imeCDD4

  6ate accessed = ne( 6ateCsession!get;astAccessed?imeCDD4

  o%t!rintlnC"@6 " K session!get@dCDD4  o%t!rintlnC"5reated " K createdD4  o%t!rintlnC";ast Accessed " K accessedD4

  // set session info if needed  9tring dataName = re)%est!getSarameterC"dataName"D4

  if CdataName V= n%ll 33 dataName!lengthCD > FD E

  9tring data8al%e = re)%est!getSarameterC"data8al%e"D4  session!setAttrib%teCdataName data8al%eD4

  L

  // rint session contents  Bn%meration e = session!getAttrib%teNamesCD4

  (hile Ce!hasMoreBlementsCDD E

  9tring name = C9tringDe!ne'tBlementCD4  9tring &al%e = session!getAttrib%teCnameD!to9tringCD4

  o%t!rintlnCname K " = " K &al%eD4

  L  L

L

)'T%'T!C

9ession @6 BQ0AB.0BB5.AF.$QQ$0B-15reated ?h% May *- 1*FFF. @9? *FF.

;ast Accessed ?h% May *- 1*FF$+ @9? *F1$

?he follo(ing data is in yo%r sessionANAN?I = 1*+$

AM = $+*1

 Y.Kiran Kumar Page +1

Page 32: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 32/51

1*. enerate ,S% pages to

a. urrent syste date

b. %age should include t"o files (either htl or 8sp files$ by using include directive.

c. %age should include t"o files (either htl or 8sp files$ by using include action.

d. :ny atheatical table by using Scriptlet Eleents (Declaration4 Epression and Scriptlet tags$.

e. %age ust perfor for"ard action.

urrent syste date

Date.8sp

<^age contenttye="te't!html" imort=",a&a!%til!">

<html>

<body><>3nbs4</>

<di& align="center">

<center><table border="F" celladding="F" cellsacing="F" (idth="$F" bgcolor="BB5A">

<tr>

<td (idth="1FF"><font size="" color="FF.FFF">3nbs46ateB'amle</font></td></tr><tr>

<td (idth="1FF"><b>3nbs45%rrent 6ate and ?ime is3nbs4<font color="FFFF">

<=ne( ,a&a!%til!6ateCD></font></b></td>

</tr>

</table></center>

</body>

</html>

+or"ard.8sp<html>

<head>

<title>?he for(ard action e'amle</title></head>

<body>

<center><h*>?he or(ard action B'amle</h*>

<,sfor(ard age="date!,s"/>

</center></body>

</html>Main.8sp

<^incl%de file="header!,s"><center>

<>?han#s for &isiting my age</>

</center><^incl%de file="footer!,s">

+ooter.8sp

 Y.Kiran Kumar Page +*

Page 33: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 33/51

<html>

<body><br><br>

<center>

<>5oyright ^ *F1$</></center>

</body>

</html>

Header.8sp

<V

int age5o%nt=F4

&oid add5o%ntCDE age5o%ntKK4

L

><add5o%ntCD4>

<html>

<head><title>?he incl%de 6irecti&e B'amle</title></head>

<body>

<center><h*>?he incl%de 6irecti&e B'amle</h*>

<>?his has been &isited<=age5o%nt>times</>

</center><br><br>

</body>

</html>

-. 6rite a ,ava %rogra using T%=7% %rotocol.

imort ,a&a!net!4imort ,a&a!io!4

 

class tciser&er E

 %blic static &oid mainC9tring argsGHD thro(s @OB'cetion

E9er&er9oc#et n1=n%ll4

tryE

n1=ne( 9er&er9oc#etC-.D4L

catchC@OB'cetion eD

E9ystem!err!rintlnC"Sort -. co%ld not be fo%nd"D4

9ystem!e'itC1D4

 Y.Kiran Kumar Page ++

Page 34: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 34/51

L

9oc#et c=n%ll4try

E

c=n1!accetCD49ystem!o%t!rintlnC"5onnection from "KcD4

L

catchC@OB'cetion eD

E9ystem!o%t!rintlnC"Accet failed"D4

9ystem!e'itC1D4

LSrintWriter o%t=ne( SrintWriterCc!getO%t%t9treamCDtr%eD4

Q%fferedeader in=ne( Q%fferedeaderCne( @n%t9treameaderCc!get@n%t9treamCDDD4

9tring n4Q%fferedeader sin=ne( Q%fferedeaderCne( @n%t9treameaderC9ystem!inDD4

9ystem!o%t!rintlnC"eady to tye no("D4

(hileCCn=sin!read;ineCDDV=n%llDE

o%t!rintlnCnD4

L

o%t!closeCD4c!closeCD4

n1!closeCD4

LL

imort ,a&a!net!4

imort ,a&a!io!4 

class tciclient

E %blic static &oid mainC9tring argsGHD thro(s @OB'cetion

E

9oc#et s=n%ll4Q%fferedeader b=n%ll4

 

tryE

s=ne( 9oc#etC@netAddress!get;ocalIostCD-.D4 b=ne( Q%fferedeaderCne( @n%t9treameaderCs!get@n%t9treamCDDD4

catchCn#no(nIostB'cetion %D

E9ystem!err!rintlnC"@ don_t #no( host"D4

9ystem!e'itCFD4

 Y.Kiran Kumar Page +$

Page 35: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 35/51

L

9tring in4(hileCCin=b!read;ineCDDV=n%llD

E

9ystem!o%t!rintlnCinD4L

 b!closeCD4

s!closeCD4

LL

0. 6rite a ,S% progra for finding total nuber of visitors in a site to keep track of active users at a given

instance of tie4 and also display the user session starting tie.

Session.8sp

<^ age imort=",a&a!io!,a&a!%til!"><6ate lastAccess?ime=ne( 6ateCsession!getlastAccess?ime?imeCDD4

9tring title="(elcome bac# to my (ebsite_4

@nteger &isit5o%nt=ne( @ntegerCFD4@nteger &isit5o%nt#ey=ne( 9tringC"&isit5o%nt"D4

9tring %ser@6#ey=ne( 9tringC"%ser@6"D4

9tring %ser@6=ne( 9tringC"AQ56"D4ifCsession!isNe(CDD

E

title="(elcome to my (ebsite"4

session!setAttrib%teC%ser@6#ey%ser@6Dsession!setAttrib%teC&isit5o%ntJeey&isit5o%ntD4

L

&isit5o%nt=C@ntegerDsession!getAttrib%teC&isit5o%nt#eyD4&isit5o%nt=&isit5o%ntK14

%ser@6=C9tringDsession!getAttrib%teC%ser@6#eyD4

session!setAttrib%teC&isit5o%ntJeey&isit5o%ntD4>

<html>

<head><title>9ession ?rac#ing</title>

</head><body>

<center><h1>9ession ?rac#ing</h1>

</center>

<table border="1" align="center"><tr bgcolor="-$-$-$">

<th>9ession info</th>

 Y.Kiran Kumar Page +

Page 36: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 36/51

<th>8al%e</th>

</tr><tr>

<td>id</td>

<td>< o%t!rintC9ession!get@dCDD4></td></tr>

<tr>

<td>5reation ?ime</td>

<td>< o%t!rintCcreate ?imeD4></td></tr>

<tr>

<td>?ime of last Access</td><td>< o%t!rintClast Access?imeD4></td>

</tr>

<tr><td>%ser id</td>

<td>< o%t!rintC%ser@6D4></td>

</tr><tr><td>N%mber of &isits</td>

<td>< o%t!rintC&isit5o%ntD4></td>

</tr></table>

</body>

</html>

12. 6rite a ,S% progra that creates a cookie on usernae "hich is send fro htl file and display the

cookie value as a response. The cookie ust be active based on the aiu active interval tie.

<  5oo#ie %id = ne( 5oo#ieC"%sername"re)%est!getSarameterC"%sername"DD4

  5oo#ie ass = ne( 5oo#ieC"ass(ord"re)%est!getSarameterC"ass(ord"DD4

  %id!setMa'AgeCFF*$D4  ass!setMa'AgeCFF*$D4

  resonse!add5oo#ieC%idD4

  resonse!add5oo#ieCassD4>

<html>  <body>

  <h1>5reation of coo#ies</h1><br>  ser @d<=re)%est!getSarameterC"%sername"D><br>

  Sass(ord<=re)%est!getSarameterC"ass(ord"D> </body>

</html>

 Y.Kiran Kumar Page +

Page 37: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 37/51

  <html> <h1>eading of 5oo#ies</h1><br/>

 <

  5oo#ie c#=n%ll4  5oo#ieGH c#s=n%ll4

  c#s=re)%est!get5oo#iesCD4

  ifCc#sV=n%llD

  E  o%t!rintlnC"<h*>o%nd coo#ie name and &al%es</h*>"D4

  forCint i=F4i<c#s!length4iKKD

  E  c#=c#sGiH4

  o%t!rintlnC"Name of the coo#ie is"Kc#!getNameCDK""D4

  o%t!rintlnC"8al%e of the coo#ie is"Kc#!get8al%eCDK"<br>"D4  L

 Y.Kiran Kumar Page +0

Page 38: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 38/51

  L

  elseEo%t!rintlnC"<h*>No 5oo#ies (as fo%nd</h*>"D4

  L

 ></html>

<  5oo#ie %id = ne( 5oo#ieC"%sername"re)%est!getSarameterC"%sername"DD4

  5oo#ie ass = ne( 5oo#ieC"ass(ord"re)%est!getSarameterC"ass(ord"DD4  %id!setMa'AgeCFF*$D4

  ass!setMa'AgeCFF*$D4

  resonse!add5oo#ieC%idD4

  resonse!add5oo#ieCassD4>

<html>  <body>

  <h1>5reation of coo#ies</h1><br>

  ser @d<=re)%est!getSarameterC"%sername"D><br>  Sass(ord<=re)%est!getSarameterC"ass(ord"D>

 </body>

</html>

 Y.Kiran Kumar Page +.

Page 39: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 39/51

  <html> <h1>eading of 5oo#ies</h1><br/>

 <

  5oo#ie c#=n%ll4  5oo#ieGH c#s=n%ll4

  c#s=re)%est!get5oo#iesCD4

  ifCc#sV=n%llD

  E  o%t!rintlnC"<h*>o%nd coo#ie name and &al%es</h*>"D4

  forCint i=F4i<c#s!length4iKKD

  E  c#=c#sGiH4

  o%t!rintlnC"Name of the coo#ie is"Kc#!getNameCDK""D4

  o%t!rintlnC"8al%e of the coo#ie is"Kc#!get8al%eCDK"<br>"D4  L

 Y.Kiran Kumar Page +-

Page 40: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 40/51

  L

  elseEo%t!rintlnC"<h*>No 5oo#ies (as fo%nd</h*>"D4

  L

 ></html>

1<. Develop 8ava progra for follo"ing SFL operations using ,DB.a. reate

b. 7nsert

c. 'pdate and

d. Delete

onsider the follo"ing schea!

Eployee (Ep@ae4 Ep@o %riary Gey4 Departent4 Salary$

:ccessDb.8ava

imort ,a&a!io!4

imort ,a&a!s)l!4class Access6b

E

 %blic static &oid mainC9tring argsGHDthro(s @OB'cetion9:;B'cetionE

try

E

5lass!forNameC"s%n!,dbc!odbc!7dbcOdbc6ri&er"D45onnection con=6ri&erManager!get5onnectionC",dbcodbcemdsn"D4

9tatement st=con!create9tatementCD4

 Y.Kiran Kumar Page $F

Page 41: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 41/51

es%lt9et rs=st!e'ec%te:%eryC"select from emtable"D4

(hileCrs!ne'tCDDE

9ystem!o%t!rintlnCrs!get@ntC1DK"Xt"Krs!get9tringC*DK"Xt"Krs!get9tringC+DK"Xt"Krs!get9trinC$DD4

Lrs!closeCD4

st!closeCD4

con!closeCD4

LcatchCB'cetion e'D

E

9ystem!o%t!rintlnC"Brror"Ke'D4L

L

L

 Y.Kiran Kumar Page $1

Page 42: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 42/51

1>. enerate a ,S% page that "ill store and retrieve the Eployee inforation fro the database.

The page should display the eployee records in a tabular forat.

reation of a contet file

5reate any folder in any dri&e as CBX7sD! @nside that folder store yo%r !,s files! Ri&e the 5onte't ath name as ,s and docQase as BX7s here docQase means the total ath (here (e are storing

o%r !,s files! ?hese changes are done in the ser&er!'ml file (hich is resent in CBXSrogram

ilesXAache 9oft(are o%ndationX?omcat !FXconfD directory!

Server.l file

<2'ml &ersion=_1!F_ encoding=_%tf._2>

<9er&er ort=".FF" sh%tdo(n="9I?6OWN">

  <;istener className="org!aache!catalina!core!Ar;ifecycle;istener" 99;Bngine="on" />  <;istener className="org!aache!catalina!core!7aser;istener" />

  <;istener className="org!aache!catalina!mbeans!9er&er;ifecycle;istener" />

  <;istener className="org!aache!catalina!mbeans!Rlobaleso%rces

  ;ifecycle;istener" />

  <RlobalNamingeso%rces>

  <eso%rce name="ser6atabase" a%th="5ontainer"

  tye="org!aache!catalina!ser6atabase"

  descrition="ser database that can be %dated and sa&ed"

  factory="org!aache!catalina!%sers!Memoryser6atabaseactory"

  athname="conf/tomcat%sers!'ml" />

  </RlobalNamingeso%rces>

 

<9er&ice name="5atalina">

 

<5onnector ort=".F.1" rotocol="I??S/1!1"

connection?imeo%t="*FFFF"redirectSort=".$$+" />

 

<5onnector e'ec%tor="tomcat?hreadSool"

  ort=".F.F" rotocol="I??S/1!1"

connection?imeo%t="*FFFF"

redirectSort=".$$+" />

 Y.Kiran Kumar Page $*

Page 43: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 43/51

  <5onnector ort=".$$+" rotocol="I??S/1!1" 99;Bnabled="tr%e"

  ma'?hreads="1F" scheme="htts" sec%re="tr%e"

  clientA%th="false" sslSrotocol="?;9" />

 

<5onnector ort=".FF-" rotocol="A7S/1!+" redirectSort=".$$+" />

<Bngine name="9tandalone" defa%ltIost="localhost" ,&mo%te=",&m1">

<Bngine name="5atalina" defa%ltIost="localhost">

 

<5l%ster className="org!aache!catalina!ha!tc!9imle?c5l%ster"/>

 

<8al&e className="org!aache!catalina!&al&es!e)%est6%mer8al&e"/>

  <ealm className="org!aache!catalina!realm!ser6atabaseealm"

  reso%rceName="ser6atabase"/>

  <Iost name="localhost" aQase="(ebas"

  %nac#WAs="tr%e" a%to6eloy="tr%e"

  'ml8alidation="false" 'mlNamesaceA(are="false">

  <8al&e className="org!aache!catalina!a%thenticator!9ingle9ignOn" />

  <8al&e className="org!aache!catalina!&al&es!Access;og8al&e" directory="logs"

 refi'="localhostaccesslog!" s%ffi'="!t't" attern="common" resol&eIosts="false"/>

 ontet pathIJ=8spJ docBaseIJE!9,spJ reloadableIJtrueJ debugIJ5J =; 

</Iost>

  </Bngine>

  </9er&ice>

</9er&er>

Table creation

irst create an emloyee table in Oracle and insert some data as belo(

5reate table emloyee Cemid &archarC1FDemname &archarC1FDsal intD

 

insert into emloyee &al%esC_eFF1__a,_1FFFFD

 insert into emloyee &al%esC_eFF*__Iarry_*FFFFD

 insert into emloyee &al%esC_eFF+__9%nil_+FFFFD

 insert into emloyee &al%esC_eFF$__Solloc#_$FFFFD

 Y.Kiran Kumar Page $+

Page 44: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 44/51

 insert into emloyee &al%esC_eFF__7onty_FFFFD

 insert into emloyee &al%esC_eFF__Jallis_FFFFD

 insert into emloyee &al%esC_eFF0__ichard_0FFFFD

reation of dsn (database source nae$

9tart5ontrol anel Administrati&e ?ools 6ata 9o%rces CO6Q5Dgo to system dsn tabclic# add

 b%ttonselect a dri&er for (hich yo% (ant to set % data so%rce Cfor Oracle Oracle in YBDselect it

and clic# finishgi&e any name in data so%rce name te'tbo'then clic# o# b%tton!

 Note Iere sername=system Sass(ord=tiger and 6sn name=dsn1

Display.8sp

<^ age imort=",a&a!s)l!" >

<html>

<body bgcolor="Tello(">

  <table border="1" (idth="+F" height="+F">

  <tr><th><font color=_ed_>BMS @6</font></th><th><font color=_ed_>BMS

 NAMB</font></th><th><font color=_ed_>9A;AT</font></th></tr>

<

5lass!forNameC"s%n!,dbc!odbc!7dbcOdbc6ri&er"D4

5onnection con=6ri&erManager!get5onnectionC",dbcodbcdsn1""system""tiger"D4

9tatement stmt=con!create9tatementCD4

es%lt9et rs=stmt!e'ec%te:%eryC"select from emloyee"D4

  (hileCrs!ne'tCDD  E

  9tring Bmloyee@d=rs!get9tringC"emid"D4

  9tring BmloyeeName=rs!get9tringC"emname"D4

  int 9alary=rs!get@ntC"sal"D4

  >

<tr>

<td><b><font color=_++FF_><=Bmloyee@d></font></b></td>

<td><b><font color=_++FF_><=BmloyeeName></font></b></td>

<td><b><font color=_++FF_><=9alary></font></b></td>

</tr><

  L

 >

 </table>

  </body>

</html>

 Y.Kiran Kumar Page $$

Page 45: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 45/51

&unning the application

%n the tomcat then (rite the belo( line in the ;

htt//localhost.F.1/,s/

Iere ,s is the 5onte't ath (hich (e mentioned in the ser&er!'ml file (hich is resent in

CBXSrogram ilesXAache 9oft(are o%ndationX?omcat !FXconfD directory!

After gi&ing the ; a set a listing (ill come here only one aears as 6islay!,s clic# it

htt//localhost.F.1/,s/6islay!,s

Output

//@nserting 6ata into 6atabase %sing 9er&let<html>

  <head>

  <title>6ata etrie&ing</title>  </head>

  <body>

  <form action="!/sho(data">

  <in%t tye="s%bmit" &al%e="@nsert 6ata"/>  </form>

  </body>

</html>

 Y.Kiran Kumar Page $

Page 46: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 46/51

7nsert.8sp

<^ age lang%age=",a&a" content?ye="te't/html">

<^age imort=",a&a!io!">

<^age imort=",a&a!s)l!">

<html>

<head>

<title>@nsert title here</title>

</head><body>

< 9tring fn=re)%est!getSarameterC"t1"D4

9tring ln=re)%est!getSarameterC"t*"D4

tryE

5lass!forNameC"s%n!,dbc!odbc!7dbcOdbc6ri&er"D!ne(@nstanceCD4

5onnection con = 6ri&erManager!get5onnectionC",dbcodbcm%rali"D4

o%t!rintlnC"5onnection s%ccess!!!"D4

o%t!rintlnC"<br/>"D4

9tatement st=con!create9tatementCD4

int i=st!e'ec%tedateC"insert into em &al%esC_"KfnK"__"KlnK"_D"D4

o%t!rintlnC"6ata is s%ccessf%lly insertedV"D4

 Y.Kiran Kumar Page $

Page 47: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 47/51

o%t!rintlnC"ro(s affected by insert "KiD4

L

catchCB'cetion eDE

o%t!rintCeD4

e!rint9tac#?raceCD4 L

> </body> </html>

 Y.Kiran Kumar Page $0

Page 48: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 48/51

1?. 6rite progras in ,ava to create threeCtier applications using ,S% and Databases

  K +or conducting onCline eaination.

  K +or displaying student ark list.

:ssue that student inforation is available in a Database "hich has been stored in a database

server.

?hree?ier Alication sing 79S and 6atabase COnline B'aminationD

)nlineEa.8sp

<^ age lang%age=",a&a" imort=",a&a!s)l!" >

<^ age imort=",a&a!io!" ><^ age imort=",a&a!%til!" >

<

9tring 9eatN%mName49tring ans1ans*ans+ans$ans4

int a1a*a+a$a4

a1=a*=a+=a$=a=F45onnection connect=n%ll4

9tatement stmt=n%ll4

es%lt9et rs=n%ll45lass!forNameC"s%n!,dbc!odbc!7dbcOdbc6ri&er"D49tring %rl = ",dbcodbcB'am9t%dent"4

connect = 6ri&erManager!get5onnectionC%rl" "" "D4

ifCre)%est!getSarameterC"action"DV=n%llDE

9eatN%m = re)%est!getSarameterC"9eatno"D4

 Name = re)%est!getSarameterC"Name"D4ans1 =re)%est!getSarameterC"gro%1"D4

ifCans1!e)%alsC"?r%e"DD

a1=4

elsea1=F4

ans* = re)%est!getSarameterC"gro%*"D4

ifCans*!e)%alsC"?r%e"DDa*=F4

else

a*=4ans+ = re)%est!getSarameterC"gro%+"D4

ifCans+!e)%alsC"?r%e"DD

a+=F4else

a+=4ans$ = re)%est!getSarameterC"gro%$"D4

ifCans$!e)%alsC"?r%e"DDa$=4

else

a$=F4ans = re)%est!getSarameterC"gro%"D4

ifCans!e)%alsC"?r%e"DD

 Y.Kiran Kumar Page $.

Page 49: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 49/51

a=F4

elsea=4

int ?otal=a1Ka*Ka+Ka$Ka4

stmt = connect!create9tatementCD49tring )%ery = "@N9B? @N?O 9t%dent?able C" K "9eatnoNameMar#s" K "D

8A;B9 C_" K9eatN%m K "_ _" K Name K "_ _"K?otalK "_D"4

int res%lt = stmt!e'ec%tedateC)%eryD4

stmt!closeCD4stmt = connect!create9tatementCD4

)%ery = "9B;B5? OM 9t%dent?able WIBB Name="K"_"KNameK"_"4

rs = stmt!e'ec%te:%eryC)%eryD4>

<html><head><title>9t%dent Mar# ;ist</title></head>

<body bgcolor=#ha#i><center>

<h*>9t%dents Mar#sheet</h*>

<h+>Name of the 5ollege 9ree 8idyani#ethan Bngineering 5ollege</h+><table border="1" cellsacing="F" celladding="F"><tr>

<td><b>9eatNo</b></td>

<td><b>Name</b></td><td><b>Mar#s</b></td>

</tr>

<(hileCrs!ne'tCDD

E

>

<tr><td><=rs!get@ntC1D></td>

<td> <=rs!get9tringC*D></td>

<td> <=rs!get9tringC+D></td></tr>

<

Lrs!closeCD4

stmt!closeCD4

connect!closeCD4>

</table></center>

<br/> <br/><br/><table>

<tr><td><b>6ate<=ne( ,a&a!%til!6ateCD!to9tringCD ></td></tr>

<tr><td><b>9ignat%re Y!T!Z! <b></td></tr></table>

<di&>

 Y.Kiran Kumar Page $-

Page 50: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 50/51

<a href="htt//localhost.F-F/OnlineB'am/OnlineB'am!,s">5lic# here to go bac#</a>

</body></html>

<LelseE>

<html><head><title>Online B'amination</title>

<scrit lang%age=",a&ascrit">

f%nction &alidationCormob,D

EifCormob,!9eatno!&al%e!length==FD

E

alertC"Sleasefill % the 9eat N%mber"D4ormob,!9eatno!foc%sCD4

ret%rn false4

LifCormob,!Name!&al%e!length==FD

E

alertC"Sleasefill % the Name"D4ormob,!Name!foc%sCD4ret%rn false4

L

ret%rn tr%e4L

</scrit>

</head><body bgcolor=lightgreen>

<center>

<h1>Online B'amination</h1>

</center><form action="OnlineB'am!,s" method="ost"

name="entry" on9%bmit="ret%rn &alidationCthisD">

<in%t tye="hidden" &al%e="list" name="action"><hr/>

<table>

<tr><td><h+>9eat N%mber </h+></td>

<td><in%t tye="te't" name="9eatno"></td>

</tr><tr>

<td><h+>Name </h+></td><td><in%t tye="te't" name="Name" size="F"></td>

</tr><tr>

<td><b>?otal Mar#s=* </b></td>

<td></td><td></td><td></td><td><b>?ime 1 Min!</b></td></tr>

</table>

 Y.Kiran Kumar Page F

Page 51: Wad Final Doc Print

7/23/2019 Wad Final Doc Print

http://slidepdf.com/reader/full/wad-final-doc-print 51/51

<hr/>

<b>1! YM; enables yo% to collect information once and re%se it in a&ariety of (ays!</b><br/>

<in%t tye="radio" name="gro%1" &al%e="?r%e">?r%e

<in%t tye="radio" name="gro%1" &al%e="alse">alse<br><br/>

<b>*! @n Modern S5 there is no cache memory!</b><br/>

<in%t tye="radio" name="gro%*" &al%e="?r%e">?r%e

<in%t tye="radio" name="gro%*" &al%e="alse">alse<br><br/>

<b>+! 7a&a9crit f%nctions cannot be %sed to create scrit fragments

that can be %sed o&er and o&er again</b><br/><in%t tye="radio" name="gro%+" &al%e="?r%e">?r%e

<in%t tye="radio" name="gro%+" &al%e="alse">alse<br>

<br/><b>$!?he 6ri&erManager class is %sed to oen a connection to a

database &ia

a 76Q5 dri&er!</b><br/><in%t tye="radio" name="gro%$" &al%e="?r%e">?r%e<in%t tye="radio" name="gro%$" &al%e="alse">alse<br>

<br/>

<b>! ?he 76Q5 and O6Q5 does not share a common arent</b><br/><in%t tye="radio" name="gro%" &al%e="?r%e">?r%e

<in%t tye="radio" name="gro%" &al%e="alse">alse<br>

<hr/><center>

<in%t tye = "s%bmit" &al%e="9%bmit">

<in%t tye = "reset" &al%e="5lear"><br><br>

</center></form>

<L>


Recommended