Вы находитесь на странице: 1из 86

Week1(a): Date:

Aim: write a Timetable program for 3rd Year B.Tech IT branch.

Sourcecode:

<html>
<head>
<title> time table</title>
</head>
<body bgcolor=”aqua”>
<table border=5 align=center height="60%" text align=center>
<caption><B><U>TIME TABLE</U></B></caption>
<tr>
<th>DAYS/PERIODS</th>
<th>9:00 TO 9:50</th><th>9:50 to 10:40</th><th>10:40 TO 10:50</th><th>10:50 TO
11:40</th><th>11:40 TO 12:30</th>
<th>12:30 TO 1:10</th><th>1:10 TO 2:00</th>
<th>2:00 TO 2:50</th><th>2:50 TO 3:40</th>
</tr>
<tr>
<th>mon</th>
<td><center>dm</td>
<td><center>mt</td>
<th rowspan=2>B<br>R</th>
<td><center>mt</td>
<td><center>cn</td>
<th rowspan=6>L<br>U<br>N<br>C<br>H</th>
<td><center>ec</td>
<td><center>ooad</td>
<td><center>sem</td>
</tr>
<tr>
<th>tue</th>
<td><center>mt</td>
<td><center>ooad</td>
<td><center>sem</td>
<td><center>ec</td>
<td><center>ec</td>
<td><center>dm</td>
<td><center>cn</td>
</tr>
<tr>
<th>wed</th>
<td><center>mt</td>
<td colspan=4><center><B>WEB TECHNOLOGIES LAB</B></td>
<td><center>dm</td>
<td><center>wt</td>
<td><center>cn</td>
</tr>
<tr>
<th>thu</th>
<td><center>ooad</td>
<td><center>sem</td>
<th rowspan=3>E<br>A<br>K</th>
<td><center>wt</td>
<td><center>wt</td>
<td><center>sem</td>
<td><center>mt</td>
<td><center>lib</td>
</tr>
<tr>
<th>fri</th>
<td><center>ec</td>
<td><center>dm</td>
<td><center>ooad</td>
<td><center>cn</td>
<td colspan=7><center><B>CN & CT LAB</B></td>
</tr>
<tr>
<th>sat</th>
<td><center>ooad</td>
<td><center>ec</td>
<td><center>dm</td>
<td><center>sem</td>
<td><center>cn</td>
<td><center>mt</td>
<td><center>wt</td>
</tr>
</body>
</html>
Output:
Week1(b): Date:

Aim: Design an Online application form using HTML form elements

Sourcecode:

<html>
<body>
<form>
<center>
<table cellpadding=4 cellspacing=2 border=0>

<th bgcolor="#CCCCFF" colspan=2>


<font size=5>ONLINE REGISTRATION</font>
<br>
<font size=1><sup>*</sup> Required Fields</font>
</th>

<tr bgcolor="#c8d8f8">
<td valign=top>
<b>First Name<sup>*</sup></b>
<br>
<input type="text" name="firstName" value="" size=15 maxlength=20 ></td>
<td valign=top>
<b>Last Name<sup>*</sup></b>
<br>
<input type="text" name="lastName" value="" size=15 maxlength=20></td>
</tr>

<tr bgcolor="#c8d8f8">
<td valign=top>
<b>E-Mail<sup>*</sup></b></td>
<td>
<input type="text" name="email" value="" size=25 maxlength=125>
<br></td></tr>
<tr bgcolor="#c8d8f8" colspan=2>
<td><b>Address<sup>*</sup></b></td>
<td>
<textarea name=address rows=3 cols=20 >
</textarea>
</td>
</tr>
<tr bgcolor="#c8d8f8">
<td>
<b>User Name<sup>*</sup></b>
</td>
<td>
<input type="text" name="userName" size=20 value="" maxlength=40>
</td>
</tr>

<tr bgcolor="#c8d8f8">
<td valign=top>
<b>Password<sup>*</sup></b>
<br>
<input type="password" name="password1" size=10 value=""
maxlength=10></td>
<td valign=top>
<b>Confirm Password<sup>*</sup></b>
<br>
<input type="password" name="password2" size=10 value=""
maxlength=10></td>
<br>
</tr>
<tr bgcolor="#c8d8f8">
<td><b>Gender<sup>*</sup></b></td>
<td>
<input type=radio name="gender">Male
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type=radio name="gender">Female
</td>
</tr>

<tr bgcolor="#c8d8f8">
<td valign=top colspan=2>
<b> Branch you are studing in<sup>*</sup></b>
<br>
<input type="checkbox" name="branch" value="cse">CSE <br>
<input type="checkbox" name="branch" value="IT">IT<br>
<input type="checkbox" name="branch" value="ECE">ECE<BR>
<input type="checkbox" name="branch" value="EEE">EEE<BR>
<input type="checkbox" name="branch" value="ME">ME<br>
</td>
</tr>

<tr bgcolor="#c8d8f8">
<td valign=top colspan=2>
<b>Would you Confirm your Details?</b>
<br>
<input type="radio" name="notify" value="Yes" checked>Yes

<input type="radio" name="notify" value="No" > No


<br><br></td>
</tr>

<tr bgcolor="#c8d8f8">
<td align=center colspan=2>
<input type="submit" value="Submit"> <input type="reset"
value="Reset">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;
<a href="c:\next.html">next>></a>
</td>
</tr>

</table>
</center>
</form>
</body>
</html>
Output:
Week2: Date:

Aim: Design following static web pages required for an Online book store
website.
a)Homepage
b)Login page
c)Catalogue page
d)cart page
e)registration page

SourceCode:

Homepage.html:

<HTML>
<frameset rows="30%,70%">

<frame name=top src="title.html">


<frameset cols="10%,*">
<frame name=left src="branches.html">
<frame name=right src="description.html">
</frameset>
</frameset>
</html>
title.html:

<html>
<head>
<title>
TIMETABLE
</title>
</head>
<body bgcolor=lightgreen>
<table border=1 width=100% align=center height=100%>
<tr>
<td colspan=5 align=center><B> <FONT COLOR=RED><MARQUEE>PITS BOOKS
STORE</MARQUEE></FONT></B> </td>
</tr>
<tr>
<th>
<a href="Description.html" target=right>logohome</a>
</th>

<th>
<a href="login.html" target=right>login</a>
</th>

<th> <a href="REGISTRATION.html" target=right>registration</a>


</th>

<th>
<a href="catologue.html" target=right>catologue</a>
</th>

<th><a href="cart.html" target=right>cart</a> </th>


</tr>
</table>

</body>

</html>
description.html:

<html>

<body bgcolor=lightcyan>

<CENTER> <H1> PITS</H1>

<H2> This site belongs to the college of<b> priyadarshini institute of technology and
sciences</b>
here in this site we can buy books in online.or we can search the data of which book we
want.further steps to login
</H2>

</body>

</html>
branches.html:

<html>
<body BGCOLOR=AQUA>
<center>

<a href="catologue.html" target=right><h1>CSE</h1></a>


<BR><BR>
<a href="l.html" target=right><h1>IT</h1></a>
<BR><BR>
<a href="l.html" target=right> <h1>ECE</h1></a>
<BR><BR>
<a href="l.html" target=right><h1>EEE</h1></a>
</center>
</pre>
</body>
</html>
Login.html:

<html>

<body bgcolor=lightblue>
<form name=loginform>
<br><br><br><br><br><br><br>
<table border=2 align=center width=20%>
<caption>LOGIN PAGE</CAPTION>
<tr>
<td>login</td>
<td><input type=text name=login></input><br></td>
</tr>

<tr>
<td>password</td>
<td><input type=password name=password></input><br></td>
</tr>

<tr>
<td align=center colspan=2><input type=submit value=submit></input>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=reset
value=clear></input></td>
</tr>

</table>
</form>
</body>

</html>
registration.html:

<html>
<head>
<title>
REGISTRATION FORM
</title>
</head>
<body bgcolor=gold>
<form name=m>
<table border=2 align=center width=50%>
<caption><marquee>REGISTRATION FORM</marquee></caption>
<tr>
<th> name</th>
<th> <input type=text name=f1>
</input>
</th>
</tr>
<tr>
<th> password</th>
<th><input type=password name=f2>
</input>
</th>
</tr>
<tr>
<th> e-mail</th>
<th> <input type=text name=f8>
<tr>
<tr>
<th> phone no.</th>
<th> <input type=text name=f9>
<tr>
<tr>
<th> gender</th>
<td>male<input type=radio name=f5>
female<input type=radio name=f5>
</td>
</tr>

<th> languages known</th>


<td> telugu<input type=checkbox name=f3>
english<input type=checkbox name=f4>
hindi <input type=checkbox name=f6>
</input>

</td>
</tr>

<tr>
<th>branch</th>
<td><select name=s>
<option name=f6>CSE</option>
<option name=f7>IT</option>
</select>
</td>
</tr>
<tr>
<th>
date of birth </th>
<td>
day <select name=chowdary>
<option value=01> 01 </option>
<option value=02> 02 </option>
<option value=03> 03 </option>
<option value=04> 04 </option>
<option value=05> 05 </option>
<option value=06> 06 </option>
<option value=07> 07 </option>
<option value=08> 09 </option>
<option value=10> 10 </option>
<option value=11> 11 </option>
<option value=12> 12 </option>
<option value=13> 13 </option>
<option value=14> 14 </option>
<option value=15> 15 </option>
<option value=16> 16 </option>
<option value=17> 17 </option>
<option value=18> 18 </option>
<option value=19> 19 </option>
<option value=20> 20 </option>

<option value=21> 21 </option>


<option value=22> 22 </option>
<option value=23> 23 </option>
<option value=24> 24 </option>
<option value=25> 25 </option>
<option value=26> 26 </option>
<option value=27> 27 </option>
<option value=28> 28 </option>
<option value=29> 29 </option>
<option value=30> 30 </option>
<option value=31> 31 </option>
</select>

month<select name=mahesh>
<option value=jan selected> jan</option>
<option value=feb> feb</option>
<option value=mar> mar</option>
<option value=apr> apr</option>
<option value=may> may</option>
<option value=jun> jun</option>
<option value=jul> jul</option>
<option value=aug> aug</option>
<option value=sep> sep</option>
<option value=oct> oct</option>
<option value=nov> nov</option>
<option value=dec> dec</option>

</select>

year <select name=trivedi>


<option value=1985> 1985 </option>
<option value=1986> 1986 </option>
<option value=1987> 1987 </option>
<option value=1988> 1988 </option>
<option value=1989> 1989 </option>
<option value=1988> 1988 </option>
<option value=1990> 1990 </option>
<option value=1990> 1990 </option>
<option value=1991> 1991 </option>
<option value=1992> 1992 </option>
<option value=1993> 1993 </option>

<option value=1994> 1994 </option>


<option value=1995> 1995 </option>
<option value=1996> 1996 </option>
<option value=1997> 1997 </option>
<option value=1998> 1998 </option>
<option value=1999> 1999 </option>
<option value=2000> 2000 </option>
<option value=2001> 2001 </option>
<option value=2002> 2002 </option>
<option value=2003> 2003 </option>
<option value=2004> 2004 </option>
<option value=2005> 2005 </option>
<option value=2006> 2006 </option>
<option value=2007> 2007 </option>
<option value=2008> 2008 </option>
<option value=2009> 2009 </option>
<option value=2010> 2010 </option>
<option value=2011> 2011 </option>

</select>
</td>

</tr>

<tr>
<th>address</th>
<th><textarea rows=5 cols=15>
</textarea>
</th>
</tr>
<tr>
<td colspan=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type=submit value=submit>

</input>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type=reset value=clear>

</input>
</td>
</tr>
</table>
</form>
</body>
</html>
catalogue.html:

<html>

<head>
<title>
catolouge
</title>

<style>

table{border-collapse:collapse}

</style>

</head>
<body bgcolor=lightpink>
<table border=1 align=center width=100% height=100%>
<tr>
<th>
<IMG SRC="html.JPG" WIDTH=100 HEIGHT=100></IMG>
</th>
<th>
<pre>
BOOK:XML BIBLE
AUTHOR: WINSTON
PUBLICATION
</PRE>
</th>
<th>
$ 40.5
</th>
<th>
<img src=addtocart.jpg></img>
</th>
</tr>
<tr>
<th>
<IMG SRC="xml.JPG" WIDTH=100 HEIGHT=100></IMG>
</th>
<th>
<pre>
BOOK:AL
AUTHOR:S.RUSSEL
PUBLICATION:PRINCETON HALL
</pre>
</th>
<th>
$ 63</th>
<th>
<img src=addtocart.jpg></img>
</th>

</tr>
<tr>
<th>
<IMG SRC="java.JPG" WIDTH=100 HEIGHT=100></IMG>
</th>
<th>
<pre>
BOOK:JAVA2
AUTHOR:WATSON
PUBLICATION:BPB PUBLICATIONS
</PRE>
</TH>
<th>
$ 50</th>
<th>
<img src=addtocart.jpg></img>
</th>
</tr>
<tr>
<th>
<IMG SRC="jsp.JPG" WIDTH=100 HEIGHT=100></IMG>
</th>
<th>
<pre>
BOOK:HTML IN 24HOURS
AUTHOR:SAM PETER
PUBLICATION:SAM PUBLICATIONS
</PRE>
</th>
<th>
$ 50</th>
<th>
<img src=addtocart.jpg></img>
</th>
</tr>
</table>
</body></html>

cart.html:

<html>

<head>
<title>
CART
</TITLE>
</HEAD>
<body bgcolor=wheat>
<table border=1 align= center width=100% height=100%>
<tr align=center>
<td><b>book name</b></td>
<td><b>price</b></td>
<td><b>quantity</b></td>
<td><b>amount</b></td>
</tr>
<tr align=center>
<td>java2</td>
<td>$35.5</td>
<td>2</td>
<td>$70.5</td>
</tr>
<tr align=center>
<td>XML bible</td>
<td>$40.5</td>
<td>1</td>
<td>$40.5</td>
</tr>
<tr align=center>
<td></td>
<td></td>
<td>total amount</td>
<td>$130.5</td>
</tr>
</table>
</body>
</html>

Output:
Week3(a) Date:
Aim: Write as java script to validate the following fileds of above
registration page.
1. Name(nam shouyd contains alphabets and the length should not be
lessthan 6 characters)
2. Password(password should not be less than 6 charcaters length)
3. Phone number (Phone number should contain 10 digits only).

Sourcecode:

Validate.html:

<HTML>

<body>
<form name=f>
<center>
name<input type=text name=username value="" onblur=check1()><br>
password<input type=password name=pass value="" onblur=check2()><br>

phonenumber<input type=text name=phno value="" onblur=check3()>

<input type=button value=submit>

</form>

<script>
function check1()
{
var a;
var len;
a=document.f.username.value;
len=a.length;
var re=new RegExp("[a-z]|[A-Z]");
var result=re.test(a)
if(!result)
{
alert("name should not contain alphabets.enter the alphabets ");
}
if(len <6)
{
alert("entered name less than 6 characters.enter above 6 characeters");
}

function check2()
{
var b;
b=document.f.pass.value;
var len=b.length;
if(len <6)
{
alert("password should not contain 6 characters.so enter minimum 6
characters");
}
}

function check3()
{
var c;
c=document.f.phno.value;
var len1=c.length;

if(len1!=10)
{
alert("the phone number is wrong.enter the exact 10 characters");
}
}
</script>
</body>
</html>
Output:
Week4(a): Date:
Aim: Design a web page using CSS (Cascading Style Sheets) Use different
font, styles:In the style definition you define how each selector should work
(font, color etc.).Then, in the body of your pages, you refer to these
selectors to activate the styles.

SourceCode:
<html>
<head>
<style>
span.headline{color:red;font-size:40px;text-align:right}
span.lowline{color:blue;font-size:50px;text-align:center}
p{font-size:22px;text-align:center;font-family:arial;text-decoration:underline}
</style>
<body>

<span class=headline>pits</span>
<span class=lowline>asdf</span>

<p>engg college</p>

</body>
</html>
Output:
Week4(b): Date:

Aim: Design a web page using CSS (Cascading Style Sheets) Use Set a
background image for both the page and single elements on the page.

SourceCode:
<html>
<head>
<style type="text/css">
body
{
background-image:url('java.jpg');
background-repeat:repeat-x repeat-y;
}
</style>
</head>

<body>
<h1 style="color:red">Hello World!</h1>
</body>

</html>
Output:
Week4(c): Date:
Aim: Design a web page using CSS (Cascading Style Sheets) Use styles for
links as
` A:link
A:visited
A:active
A:hover

SourceCode:
<html>
<head>
<style type="text/css">
a:link {color:red;} /* unvisited link */
a:visited {color:#00FF00;text-decoration:none} /* visited link */
a:hover {color:#FF00FF;} /* mouse over link */
a:active {color:#0000FF;} /* selected link */
</style>
</head>

<body>
<p><b><a href="ex.html" target="_blank">This is a link</a></b></p>
<p><b>Note:</b> a:hover MUST come after a:link and a:visited in the CSS
definition in order to be effective.</p>
<p><b>Note:</b> a:active MUST come after a:hover in the CSS definition in order
to be effective.</p>
</body>
</html>
Output:
Week4(d): Date:
Aim: Design a web page using CSS (Cascading Style Sheets) Use different
type of cursors.

SourceCode:
<html>

<head>
<style>
p.a{cursor:auto}
p.c{cursor:crosshair}
p.d{cursor:default}
p.e{cursor:e-resize}
p.p{cursor:progress}
p.w{cursor:wait}
p.t{cursor:text}
p.po{cursor:pointer}

</style>

</head>

<body>

<center>
<h1 style="color:red">Mouse over the words to change the cursor.</h1>
<p class=a>autotext</p>
<p class=c>crosshairtext</p>
<p class=d>defaulttext</p>
<p class=e>e-resizetext</p>
<p class=p>progresstext</p>
<p class=w>waittext</p>
<p class=t>text</p>
<p class=po>pointertext</p>
</body>
</html>
Output:
Week4(e): Date:

Aim: Design a web page using CSS (Cascading Style Sheets) Use Layers

SourceCode:
<html>
<body>
<center>

<div style="position:relative; font-size:50px; z-index:2;color:red">LAYER 1</div>


<div style="position:relative; top:-50; left:5; color:red; font-size:80px; zindex:
1"><img src="java.jpg"></img></div>

<div style="position:relative; font-size:50px; z-index:2;"><img src="java.jpg"></img>


</div>
<div style="position:relative; top:-100; left:5; color:red; font-size:80px; zindex:
1">LAYER 2</div>

</body>
</html>
Output:
Week5: Date:

Aim: Write an XML file which will display the Book information which
includes the following:
1) Title of the book
2) Author Name
3) ISBN number
4) Publisher name
5) Edition
6) Price
Write a Document Type Definition (DTD) to validate the above XML file.
Display the XML file as follows.
The contents should be displayed in a table. The header of the table should
be in color GREY. And the
Author names column should be displayed in one color and should be
capitalized and in bold. Use your
own colors for remaining columns.
Use XSL and CSS for the above purpose.
Note: Give at least for 4 books. It should be valid syntactically.

SourceCode:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE books SYSTEM "book.dtd">
<?xml-stylesheet type="text/xsl" href="book.xsl"?>
<books>
<book>
<title>WEBTECHNOLOGIES</title>
<authorname>GATES</authorname>
<isbnnumber>123456</isbnnumber>
<pubname>WILLEY</pubname>
<edition>FIRST</edition>
<price>500</price>
</book>
<book>
<title>COMPUTERNETWORKS</title>
<authorname>WILLIAM STALLINGS</authorname>
<isbnnumber>234567</isbnnumber>
<pubname>PEARSON</pubname>
<edition>SECOND</edition>
<price>600</price>
</book>
<book>
<title>ECOMMERCE</title>
<authorname>Morris</authorname>
<isbnnumber>45678</isbnnumber>
<pubname>Pearson</pubname>
<edition>4</edition>
<price>2000</price>
</book>
<book>
<title>Network management</title>
<authorname>Morris</authorname>
<isbnnumber>78945</isbnnumber>
<pubname>Pearson</pubname>
<edition>5</edition>
<price>400</price>
</book>
<book>
<title>Grid Computing </title>
<authorname>Fellenstein</authorname>
<isbnnumber>25874</isbnnumber>
<pubname>Pearson</pubname>
<edition>7</edition>
<price>350</price>
</book>
<book>
<title>Mobile Communications</title>
<authorname>Jochen Schiller</authorname>
<isbnnumber>14785</isbnnumber>
<pubname>Addison-Wesley</pubname>
<edition>6</edition>
<price>2000</price>
</book>

</books>
book.dtd
<!ELEMENT books (book+)>
<!ELEMENT book (title,authorname,isbnnumber,pubname,edition,price)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT authorname (#PCDATA)>

<!ELEMENT isbnnumber (#PCDATA)>


<!ELEMENT pubname (#PCDATA)>
<!ELEMENT edition (#PCDATA)>
<!ELEMENT price (#PCDATA)>

book.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<body>
<h2>My BOOKCollection</h2>
<table border="1">
<tr bgcolor="AQUA">
<th>Title</th>
<th>AUTHOR</th>
<th>ISBN</th>
<th>PUBLISHERNAME</th>
<th>EDITION</th>
<th>PRICE</th>

</tr>
<xsl:for-each select="books/book">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="authorname"/></td>
<td><xsl:value-of select="isbnnumber"/></td>
<td><xsl:value-of select="pubname"/></td>
<td><xsl:value-of select="edition"/></td>
<td><xsl:value-of select="price"/></td>

</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Output:
Week6: Date:

Aim:Install TOMCAT web server and APACHE.


While installation assign port number 4040 to TOMCAT and 8080 to APACHE.
Make sure
that these ports are available i.e., no other process is using this port.

Installation Steps:
Week7: Date:

Aim:Write the Servelt for the following welcomepage consisting of one


dropdown box containing ‘yellow’ and ‘red’ options.Based on the request
it will open the specified page with backgroundcolor is ‘yellow ‘or ‘red’.

Procedure:
1)Create an application folder in any drive in system like “APPFOLDER”
2)Create a WEB-INF folder in APPFOLDER.
3)Create classes folder in WEB-INF folder and write a “web.xml” file in the same
directory.
4)Place the .class files in classes directory after successful compilation of corresponding
.java files using “servlet-api.jar” set as a classpath.
5)Place .html files and .jsp files under application folder i.e;APPFOLDER.
6)Place this application folder under Tomcat webserver ‘webapps’ directory
i.e;C:\Tomcat5.5\webapps.
7)Finally start the server and run the application using
http://localhost:4040/appfolder/welcome.html on the client’s web browser.

SourceCode:

welcome.html:
<html>
<body bgcolor=#efegff>

<form action="sample">

<select name="opt">
<option value="1">yellow
<option value="2">red
</select>
<input type="submit"/>

</form>

</body>

</html>
Page1.html:

<HTML>
<BODY bgcolor=yellow>
This is yellow
</BODY>
</HTML>

Page2.html:

<HTML>
<BODY bgcolor=red>
This is red
</BODY>
</HTML>
Web.xml:

<web-app>
<servlet>
<servlet-name>xx</servlet-name> <servlet-class>SampleServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>xx</servlet-name>
<url-pattern>/sample</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>welcome.html</welcome-file> </welcome-file-list>
</web-app>
SampleServlet.java:

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class SampleServlet extends HttpServlet


{
public void doGet(
HttpServletRequest req,
HttpServletResponse resp )
throws ServletException,IOException
{
String no = req.getParameter("opt");
int n = Integer.parseInt( no );

if( n == 1 )
resp.sendRedirect("yellow.html");
else
resp.sendRedirect("red.html");
}
}
OUTPUT:

:
Week8: Date:

Aim: Read the user id and passwords entered in the Login form and
authenticate
with the values (user id and passwords )
If he is a valid user(i.e., user-name and password match) you
should welcome him by
name(user-name) else you should display “ You are not an
authenticated user “.

Procedure:

1)Create an application folder in any drive in system like “APPFOLDER”


2)Create a WEB-INF folder in APPFOLDER.
3)Create classes folder in WEB-INF folder and write a “web.xml” file in the same
directory.
4)Place the .class files in classes directory after successful compilation of corresponding
.java files using “servlet-api.jar” set as a classpath.
5)Place .html files and .jsp files under application folder i.e;APPFOLDER.
6)Place this application folder under Tomcat webserver ‘webapps’ directory
i.e;C:\Tomcat5.5\webapps.
7)Finally start the server and run the application using
http://localhost:4040/APPFOLDER/lOGIN.HTML on the client’s web browser.

Sourcecode:

Login.html:

<html>
<body>
<form action="login" method="post">
<MARQUEE>WELCOME TO PRIYADARSINI INSTITUTE OF TECHNOLOGY AND
SCIENCE</MARQUEE>
<center>
USERNAME <INPUT TYPE="text" NAME="uname"> <BR>

PASSWORD <INPUT TYPE="password" name="pwd"><BR>


<INPUT TYPE="submit" value="Login" style="font-weight: 700; background-color:
#FF0000">

</form>

</BODY>
</HTML>

Web.xml:

<web-app>

<servlet>
<servlet-name>aa</servlet-name>
<servlet-class>LoginServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>aa</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>login.html</welcome-file>
</welcome-file-list>

</web-app>
LoginServlet.java:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class LoginServlet extends HttpServlet


{
public void doPost(
HttpServletRequest req,
HttpServletResponse resp )
throws ServletException,IOException
{

String uname = req.getParameter("uname");


String pwd = req.getParameter("pwd");
PrintWriter pw=resp.getWriter();

if( uname == null || pwd == null )


{

resp.sendRedirect("Login.html");
return;
}

if(!(uname.equals("pits") && pwd.equals("pits")))


{
pw.println("<h1>you are not authenticated person to access the web
resources</h1>");
pw.println("<h1><a href=login.html>relogin</a></h1>");
return;
}

pw.println("<center>your username is:<h1>"+uname+"</h1>");


pw.println("your password is:<h2>"+pwd+"</h2>");

}
Output:
Week9: Date:

Aim:Write a JSP which does the following job:


To enter the details of productcode as 100 or 200 or 300
,Description,quantity then calculate the amount.

Procedure:

1)Create an application folder in any drive in system like “APPFOLDER”


2)Create a WEB-INF folder in APPFOLDER.
5)Place .html files and .jsp files under application folder i.e;APPFOLDER.
6)Place this application folder under Tomcat webserver ‘webapps’ directory
i.e;C:\Tomcat5.5\webapps.
7)Finally start the server and run the application using
http://localhost:4040/APPFOLDER/Product.html on the client’s web browser.

Sourcecode:

Product.html:

<HTML>
<BODY>

<form action="order.jsp" method="post">


<center><h2>

Product Code
<INPUT TYPE="text" NAME="code">

<br>
Description
<INPUT TYPE="text" NAME="des">

<br>
Quantity
<INPUT TYPE="text" NAME="qty">
<br>
<INPUT TYPE="submit" value="order">

</h2>
</form>

</BODY>
</html>
order.jsp:

<%
int code = Integer.parseInt(
request.getParameter("code")
);

String des = request.getParameter("des");

double qty = Double.parseDouble(


request.getParameter("qty")
);

double rpi = 0;
double amount = 0;

switch( code )
{
case 100 : rpi = 100; break;
case 200 : rpi = 190; break;
case 300 : rpi = 100.50; break;
default : rpi = 200;
}

amount = qty * rpi;


%>

<html>
<body>

<h2>
Your order accepted & order details
<br>
Product Code : <%= code %>
<br>
Description : <%= des %>
<br>
Quantity : <%= qty %>

<br>

Rate Per Item : <%= rpi %>


<br>
Amount : <%= amount %>
</body>
</html>
OUTPUT:
Week10: Date:

Aim:

Implement Student Information System(SIS) for Priyadarsini Institute Of


Technology And Science college.Use the JSP/Servlet/database Combination
for this application. The student details are inserted in ORACLE Database
and thes details are retrieved whenever nesscessary

Procedure:

1)Create an application folder in any drive in system like “APPFOLDER”

2)Create a WEB-INF folder in APPFOLDER.

4)Place .html files and .jsp files under application folder i.e;APPFOLDER.

5)Place this application folder under Tomcat webserver ‘webapps’ directory


i.e;C:\Tomcat5.5\webapps.

6)Create Data Source Name(DSN) for database connection.i.e;Start->Settings-


>ControlPanel->AdministrativeTools-> Data Sources (ODBC)->SYSTEMDSN(tab)-
>Add->Microsoft ODBC For Oracle->gangs->OK.

7)Finally start the server and run the application using


http://localhost:4040/APPFOLDER/welcome.html on the client’s web browser.
SourceCode:

Welcome.html

<HTML>
<BODY>

<center>

<h2> Welcome to priyadarsini student details</h2>

<a href="StudentDetails.jsp">
StudentDetails
</a>

<br>

<a href="Enrollment.jsp">
Enroll Student
</a>

</center>
</BODY>
</HTML>
Enrollment.jsp:

<html>
<body>

<form action="Enroll" method="post">

<center>

Student No <INPUT TYPE="text" NAME="sno"/>


<br>
Student Name <INPUT TYPE="text" NAME="sna"/>
<br>
Course <INPUT TYPE="text" NAME="course" />
<br>

<INPUT TYPE="submit" value="Enroll" />

</center>

</form>

</body>
</html>
StudentDetails.jsp:

<%@ page import="java.sql.*" %>

<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con =
DriverManager.getConnection(
"jdbc:odbc:gangs","scott","tiger" );
%>

<h1>connection created</h1>

<%

Statement st = con.createStatement();
ResultSet rs =
st.executeQuery("select * from student");
%>
<h2>asdfasdfads</h2>

<html>
<body>

<center>

<h2> Student Details </h2>

<table border=2>
<thead>
<th> StudentNO </th>
<th> StudentName</th>
<th> Course </th>
</thead>

<%
while( rs.next() ) {
%>

<tr>
<td> <%= rs.getString(1) %> </td>
<td> <%= rs.getString(2) %> </td>
<td> <%= rs.getString(3) %> </td>
</tr>

<% } %>

</table>

</center>

</body>
</html>
Web.xml:

<web-app>
<servlet>
<servlet-name>any</servlet-name>
<servlet-class>EnrollServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>any</servlet-name>
<url-pattern>/Enroll</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>welcome.html</welcome-file>
</welcome-file-list>
</web-app>
EnrollServlet.java:

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;

public class EnrollServlet extends HttpServlet


{
public void doPost(
HttpServletRequest req,
HttpServletResponse resp )
throws ServletException,IOException
{
String no = req.getParameter("sno");
String name = req.getParameter("sna");
String course = req.getParameter("course");
PrintWriter pw=resp.getWriter();

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con =
DriverManager.getConnection(
"jdbc:odbc:gangs","scott","tiger");

PreparedStatement ps =
con.prepareStatement(
"insert into student values(?,?,?)");

ps.setString(1,no);
ps.setString(2,name);
ps.setString(3,course);
ps.execute();
con.close();
resp.sendRedirect("welcome.html");
}
catch (Exception e)
{
throw new ServletException(e);
}
}
}
OUTPUT:
When click on enrollstudent link ,it will displays ,
When click on studentdetails link,it will displays

Вам также может понравиться