Internet Technologies and Services Lab Manual
Internet Technologies and Services Lab Manual
www.btechsmartclass.com
For Study materials, Lab manuals, Lecture presentations (PPTs), Video lectures, Seminar topics and Projects visit
www.btechsmartclass.com
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 1 of 72
LAB MANUAL
OBJECTIVE
Write syntactically correct HTTP messages and describe the semantics of common HTTP
methods
and header fields
Discuss differences between URIs, URNs, and URLs, and demonstrate a detailed understanding
of
http-scheme URLs, both relative and absolute
Describe the actions, including those related to the cache, performed by a browser in the process
of
visiting a Web address
Install a web server and perform basic administrative procedures, such as tuning communication
parameters, denying access to certain domains, and interpreting an access log
hyperlinks, images, lists, tables, and forms
Use CSS to implement a variety of presentation effects in HTML and XML documents,
including
explicit positioning of elements
Demonstrate techniques for improving the accessibility of an HTML document
LIST OF PROGRAMS
1. Develop static pages (using Only HTML) of an online Book store. The pages should resemble:
www.amazon.com the website should consist the following pages.
Home page, Registration and user Login
User Profile Page, Books catalog
Shopping Cart, Payment By credit card
Order Conformation
2. Validate the Registration, user login, user profile and payment by credit card pages using
javaScript
3. Create and save an XML document at the server, which contains 10 users information. Write a
program, which takes User Id as an input and returns the user details by taking the user
information from the XML document.
4. Install TOMCAT web server. Convert the static web pages of assignments 2 into dynamic web
Pages using Servlets and cookies. Hint: Users information (user id, password, credit card
number) would be stored in web.xml. Each user should have a separate Shopping Cart.
5. Redo the previous task using JSP by converting the static web pages of assignments 2 into
dynamic web pages. Create a database with user information and books information. The
books catalogue should be dynamically loaded from the database. Follow the MVC
architecture while doing the website.
6. Implement the “Hello World!” program using JSP Struts Framework.
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 2 of 72
1. Develop static pages (using Only HTML) of an online Book store. The pages should
resemble: www.amazon.com the website should consist the following pages.
Home page, Registration and user Login
User Profile Page, Books catalog
Shopping Cart, Payment By credit card
Order Conformation
<html>
<head>
<title> Welcome to AMAZON Ebook's website</title>
</head>
<frameset rows="108,*" >
<frame name=top src="top.html" noresize frameborder=0 scrolling=no />
<frameset cols="80,*">
<frame name=left noresize scrolling=no frameborder=0 src="left.html">
<frame name=right noresize frameborder=0 src="right.html">
</frameset>
</frameset>
</html>
Top.html
<html>
<head>
<title> Welcome to AMAZON website</title>
<style type="text/css">
td{
cursor:pointer; color: #000066; font-weight:bolder; border:#665599 1 solid ;
}
marquee{background: #556677; color:#f5f5f5}
</style>
</head>
<body bgcolor=#D6E9EF>
<table width=100% align="center" cellpadding="0" cellspacing="2">
<tr>
<th width=20%><img src="images\amazon.jpeg" alt=logo /></th>
<th colspan=4> <h2><marquee scrollamount=2 scrolldelay=10 behavior=alternate>
WORLD BEST ONLINE EBOOKS WEBSITE
</marquee></h2></th></TR>
<tbody align=center bgcolor=#Ffdfdf>
<tr>
<a href="right.html" target="right"><td width=20%>Home</td></a>
<a href="login.html" target="right"><td width=20%>Login</td></a>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 3 of 72
right.html
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<center>
<h3>Welcome to Amazon Website</h3>
<p>Shopping at <font size=5>AMAZON</font> can be both <font size=5>fun</font>
and <font size=5>savings</font>.</br>Shop with us in this special <font
size=5>discount</font> season and save upto <font size=5>50%</font> on all your
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 4 of 72
purchases.</br></p>
<br/><br/><br/><br/><br/><br/><br/><br/><h4><font color="red">
(C) 2008 All rights reserved by Amazon ebooks
</body>
</html>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 5 of 72
Login.html
<html>
<head>
<title> Welcome to AMAZON website</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body >
<center>
<h3> Enter Login Details</h3> <br/>
<form name="f1" onsubmit="return form1_validation()">
<table align="center" >
<tr>
<td> User ID</td>
<td> <input type="text" name="username"></td>
</tr>
<tr>
<td> Password</td>
<td> <input type="password" name="password"></td>
</tr>
<tr><td></td>
<td><input type="submit" value="submit">
<input type="reset" value="reset"></td>
</tr>
<tr>
<td colspan=2>Forgot my User ID or Password</td>
</tr>
</table>
</body>
</html>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 6 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 7 of 72
Registration.html
<html>
<head>
<title> Welcome to AMAZON website</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="validation.js">
</script>
</head>
<body>
<center>
<h3>Registration Form </h3>
<br/>
<form name="f1" onsubmit="return form1_validation()">
<table cellpadding="1" align="center" >
<tr> <td> Name:*</td>
<td> <input type="text" name="username"></td></tr>
<tr> <td>Password:*</td>
<td> <input type="password" name="password"></td></tr>
<tr> <td>Email ID:*</td>
<td> <input type="text" name="email"></td></tr>
<tr> <td>Phone Number:*</td>
<td> <input type="text" name="phno"></td></tr>
<tr> <td valign="top">Gender:*</td>
<td> <input type="radio" name="radio" value="1">Male<br>
<input type="radio" name="radio" value="2">Female</td></tr>
<tr> <td>Date of Birth:*</td>
<td> dd: <select name=dd >
<option> </option>
<script type="text/javascript">
for(i=1;i<=31;i++)
document.write("<option value=i>"+i+"</option>");
</script> </select>
mm: <select name=mm>
<option> </option>
<script type="text/javascript">
for(i=1;i<=12;i++)
document.write("<option value=i>"+i+"</option>");
</script> </select>
yyyy: <select name=yyyy>
<option> </option>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 8 of 72
<script type="text/javascript">
for(i=1880;i<=2008;i++)
document.write("<option value=i>"+i+"</option>");
</script> </select>
</td></tr>
<tr> <td valign="top">Language Known:*</td>
<td> <input type="checkbox" name="checkbox" value="English">English<b <input
type="checkbox" name="checkbox" value="Telugu">Telugu<br>
<input type="checkbox" name="checkbox" value="Hindi">Hindi<br>
<input type="checkbox" name="checkbox" value="Tamil">Tamil
</td></tr>
<tr> <td valign="top">Address:*</td>
<td><textarea name="address"></textarea></td>
<tr><td></td><td><input type="submit" value="submit" hspace="10">
<input type="reset" value="reset"></td></tr>
<tr> <td colspan=2 >*<font color="#FF0000">fields are mandatory</font>
</td>
</tr>
</table>
</center>
</body>
</html>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 9 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 10 of 72
Catalogue.html
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<center>
<h3>Ebooks Catalogue</h3>
<table width=90% align="center" bgcolor="#E1EEFF">
<tbody bgcolor="#999999">
<tr> <th><hr>Book <hr></th>
<th><hr>Details<hr></th>
<th><hr>Price<hr></th>
<th><hr>Options<hr></th> </tr>
</tbody>
<tbody align="center">
<tr> <td><img src="images/000327738-min-1.jpg" ></td>
<td> Title: Office 2007 Server<br/> Author: Raja<br/>
Publicher:Tata Mc.Grawhill</td>
<td>Rs. 1200/-</td>
<td> <input type="button" value="Add to cart"></td> </tr>
<tr> <td><img src="images/000266974-min-1.jpg"></td>
<td>Book: Electronics Projects <br/>Author: Robert Tom
<br>
Public: Indian Ebook Mfg. <br><td align="center">Rs. 1000/-</td>
<td align="center"> <input type="button" value="Add to cart"></td> </tr>
<tr> <td align="center"><img src="images/000331427-min-1.jpg" ></td>
<td>Book: Solar Power Your Home <br/>Author: Albert<br>
Publicher: Andhra Mc.hill<br> <td align="center">Rs. 9000/-</td>
<td align="center"> <input type="button" value="Add to cart"></td> </tr>
</tbody>
</table>
</center>
<p>For more ebooks catagory, visit side panel links</p>
</body>
</html>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 11 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 12 of 72
Cart.html
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<center>
<h3>Cart</h3>
<table width=90% align="center" bgcolor="#E1EEFF">
<tbody bgcolor="#999999">
<tr> <th width=40%><hr>BookName<hr></th>
<th width=20%><hr>Price<hr></th>
<th width=20%><hr>Quantity<hr></th>
<th width=20%><hr>Amount<hr></th> </tr>
</tbody>
<tbody align=center>
<tr> <td>Office 2007 Server </td>
<td>Rs. 1200/-</td>
<td>2</td>
<td>Rs. 2400/-</td></tr>
<tr> <td>Solar Power Your Home</td>
<td>Rs. 9000/-</td>
<td>1</td>
<td>Rs. 9000/-</td></tr>
<tr > <td> </td>
<td ><hr><font color="#996600">Total Amount:</font><hr></td>
<td><hr>3<hr></td>
<td><hr>Rs. 11400/-<hr></td> </tr>
<tr> <td></td> <td></td> <td></td>
<td bgcolor="#FFCCCC"><a href="catalogue.html">Continue
Shopping...</a></td>
</tbody>
</table>
</body>
</html>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 13 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 14 of 72
CSE.html
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<center>
<h3>Computer Science & Engineering Catalogue </h3>
<table width=90% align="center" bgcolor="#E1EEFF">
<tbody bgcolor="#999999">
<th width=25% >BOOK</th>
<th width="35%">DETAILS</th>
<th width="20%">PRICE</th>
<th width="20%">OPTION</th></tbody>
<tbody align="center">
<tr>
<td align="center"><img src="images/000327738-min-1.jpg" width="90"
height="120" ></td>
<td align="center"> Title: Office 2007 Server<br> Author: B.R.Prathap <br/>
Publicher:Tata Mc.Grawhill</td>
<td align="center">Rs. 1200/-</td>
<td align="center"> <input type="button" value="Add to cart"></td>
</tr>
<tr>
<td align="center"><img src="images/it1.jpg" width="90" height="120"></td>
<td align="center"> Title: Electronics Projects<br>Author: Prathap r<br/>
Publicher:Tata Mc.Grawhill</td>
<td align="center">Rs. 1000/-</td>
<td align="center"> <input type="button" value="Add to cart"></td>
</tr>
<tr>
<td align="center"><img src="images/java1.gif" width="90" height="120" ></td>
<td align="center"> Title: Solar Power Your Home<br/>Author: Jhanaki
Ramaya Sir <br/>Publicher:Tata Mc.Grawhill</td>
<td align="center">Rs. 9000/-</td>
<td align="center"> <input type="button" value="Add to cart"></td>
</tr>
</tbody>
</table></center></body> </hmtl>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 15 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 16 of 72
ECE.html
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor=#ffffa0>
<center>
<h3>Electronics Communication Engineering Catalogue </h3>
<table width=90% align="center" bgcolor="#E1EEFF">
<tr> <th width=25% >BOOK</th>
<th width="35%">DETAILS</th><th width="20%">PRICE</th>
<th width="20%">OPTION</th> </tr> </tbody>
<tr> <tbody align=center>
<td><img src="images/000266974-min-1.jpg" height=120
width=90></td>
<td>Book: Electronics Projects <br> Author: Robert Tom <br>
Public: Indian Ebook Mfg. <br> </td>
<td align="center">Rs. 1000/-</td>
<td><input type="button" name="Add to cart" value="Add to
cart"></td></tr>
<tr>
<td><img src="images\digital.jpg" height=120
width=90></img></td>
<td>Book: Digital Communication System <br> Author: Howel
Albert <br> Public: Tata Mc.Grawhill<br> </td>
<td align="center">Rs. 1000/-</td>
<td><input type="button" name="Add to cart" value="Add to
cart"></td></tr>
<tr>
<td><img src="images\analog.jpg" height=120
width=90></img></td>
<td>Book: Digital and Analog Communications<br>Author:
Weinberg<br>
Public: Tata Mc.Grawhill<br> </td>
<td align="center">Rs 1200/-</td>
<td><input type="button" name="Add to cart" value="Add to
cart"></td></tr>
</table>
</center>
</body></html>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 17 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 18 of 72
EEE.html
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor=#ffffa0>
<center>
<h3>Eletrical & Electronics Engineering Catalogue</h3>
<table width=90% align="center" bgcolor="#E1EEFF">
<tbody bgcolor="#999999">
<tr> <th width=25% >BOOK</th>
<th width="35%">DETAILS</th>
<th width="20%">PRICE</th>
<th width="20%">OPTION</th></tr>
</tbody>
<tr> <tbody align=center>
<td><img src="images/eleceng.jpg" height=120
width=90></img></td>
<td>Book:IntelMicroProcessors<br>Author:Hibert Schildt<br>
Publicher: Hyberabad Books Corp. <br>
<td align="center">Rs. 2100/-</td>
<td><input type="button" name="Add to cart" value="Add to
cart"></td></tr>
<tr> <td><img src="images/elec.jpg" height=120 width=90></img></td>
<td>Book: Electrical & Electronics <br> Author: Rama Krishna.
K <br>
Publicher:Tata Mc.Grawhill<br> </td>
<td align="center">Rs. 1250/-</td>
<td><input type="button" name="Add to cart" value="Add to
cart"></td></tr>
<tr> <td><img src="images/000331427-min-1.jpg" height=120
width=90></img></td>
<td>Book: Solar Power Your Home <br>Author: Albert<br>
Publicher: Andhra Mc.hill<br> </td>
<td align="center">Rs 9000/-</td>
<td><input type="button" name="Add to cart" value="Add to
cart"></td></tr>
</table>
</center>
</body></html>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 19 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 20 of 72
2. Validate the registration, user login, user profile and payment by credit card pages using JavaScript.
Validation.js
function form1_validation()
{
//Username Validation
if(f1.username.value=="")
{
alert("You must enter a User Name");
f1.username.focus();
return false;
}
if(f1.username.value.length<3)
{
alert("User Name must consist of atleast 3 character");
f1.username.focus();
return false;
}
var checkStr=f1.username.value;
for(i=0;i<checkStr.length;i++)
if(!(checkStr.charCodeAt(i)>=65&&checkStr.charCodeAt(i)<=91)
&& !(checkStr.charCodeAt(i)>=97 && checkStr.charCodeAt(i)<=122))
{
alert("Please enter valid User Name");
f1.username.focus();
return false;
}
//Password Validation
if(f1.password.value.length<6)
{
alert("Please enter Password not less than 6");
f1.password.focus();
return false;
}
if(!(f1.password.value==f1.password1.value))
{
alert("Please re-enter corrert Password");
f1.password1.focus();
return false;
}
//email validation
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 21 of 72
flag=true;
if(f1.email.value=="")
flag=false;
var Str=f1.email.value;
if(allValidChars(Str))
for(i=0;i<Str.length;i++)
if(Str.charAt(i)=="@")
{
if((Str.substr(i+1,9)=="yahoo.com")||(Str.substr(i+1,9)=="gmail.com"))
{
flag=true;
break;
}
}
else
flag=false;
if(!(flag))
{
alert("Please enter a valid Email ID");
f1.email.focus();
return false;
}
//phone number validation
flag=true;
if(f1.phno.value.length!=10)
flag=false;
var phno=f1.phno.value;
for(i=0;i<phno.length;i++)
if(!(phno.charCodeAt(i)>=48&&phno.charCodeAt(i)<=57))
flag=false;
if(!flag)
{
alert("Please enter valid Phone Number");
f1.phno.focus();
return false;
}
//gender validation
flag=false;
for(i=0;i<f1.radio.length;i++)
if(f1.radio[i].checked)
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 22 of 72
flag=true;
if(!(flag))
{
alert("Please choose a Gender");
return false;
}
//Date of birth validation
if((f1.dd.selectedIndex<=0)||(f1.mm.selectedIndex<=0)||(f1.yyyy.selectedIndex<=0))
{
alert("Please choose a Date of Birth");
f1.phno.focus();
return false;
}
//checkbox validation
flag=false;
for (i = 0; i < f1.checkbox.length; i++)
{
if (f1.checkbox[i].checked)
flag = true;
}
if(!(flag))
{
alert("Please select at least one of the \"Language\" options.");
return false;
}
//address validation
if(f1.address.value.length<25)
{
alert("Please enter a Correct Address");
return false;
}
}
function allValidChars(email)
{
var validchars = "[email protected]_";
for (i=0; i < email.length; i++)
{
var letter = email.charAt(i).toLowerCase();
if (validchars.indexOf(letter) == -1)
return false;
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 23 of 72
} return true;
}
Login.html
<html>
<head>
<title> Welcome to AMAZON website</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="validation.js"></script>
</head>
<body >
<center>
<h3> Enter Login Details</h3>
<br/>
<form name="f1" onsubmit="return form1_validation()">
<table align="center" >
<tr> <td> User ID</td>
<td> <input type="text" name="username"></td> </tr>
<tr> <td> Password</td>
<td> <input type="password" name="password"></td> </tr>
<tr> <td></td>
<td><input type="submit" value="Submit"></td>
<input type="reset" value="Reset"></td> </tr>
<tr> <td colspan=2>Forgot my User ID or Password</td>
</tr>
</table>
</html>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 24 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 25 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 26 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 27 of 72
Registration.html
<html>
<head>
<title> Welcome to AMAZON website</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="validation.js"></script> </head>
<body>
<center><h3> Registration Form </h3> <br/>
<form name="f1" onsubmit="return form1_validation()">
<table cellpadding="1" align="center" >
<tr>
<td> <input type="text" name="username"></td> </tr>
<tr> <td>Password:*</td>
<td> <input type="password" name="password"></td> </tr>
<tr> <td>Email ID:* </td>
<td> <input type="text" name="email"></td> </tr>
<tr> <td>Phone Number:*</td>
<td> <input type="text" name="phno"></td> </tr>
<tr> <td valign="top">Gender:*</td>
<td> <input type="radio" name="radio" value="1">Male<br>
<input type="radio" name="radio" value="2">Female</td> </tr>
<tr> <td>Date of Birth:*</td>
<td> dd: <select name=dd > <option> </option>
<script type="text/javascript">
for(i=1;i<=31;i++)
document.write("<option value=i>"+i+"</option>");
</script> </select>
mm: <select name=mm> <option> </option>
<script type="text/javascript">
for(i=1;i<=12;i++)
document.write("<option value=i>"+i+"</option>");
</script> </select>
yyyy: <select name=yyyy> <option> </option>
<script type="text/javascript">
for(i=1880;i<=2008;i++)
document.write("<option value=i>"+i+"</option>");
</script> </select> </td> </tr>
<tr> <td valign="top">Language Known:*</td>
<td> <input type="checkbox" name="checkbox" value="English">English<br>
<input type="checkbox" name="checkbox" value="Telugu">Telugu<br>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 28 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 29 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 30 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 31 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 32 of 72
3. Create and save an XML document at the server, which contains 10 users information. Write a program
which takes User Id as input and returns the user details by taking the user information from the XML
document
student.dtd:
<!ELEMENT student(rollnum,name,parntname,branch,year,addr,email,phno)>
<!ELEMENT roll_no(#PCDATA)>
<!ELEMENT name(first_name,last_name)>
<!ELEMENT first_name(#PCDATA)>
<!ELEMENT last_name(#PCDATA)>
<!ELEMENT father_name(fname,mname,lname)>
<!ELEMENT first_name(#PCDATA)>
<!ELEMENT last_name(#PCDATA)>
<!ELEMENT branch(#PCDATA)>
<!ELEMENT year(#PCDATA)>
<!ELEMENT address(door_no,street,city)>
<!ELEMENT door_no(#PCDATA)>
<!ELEMENT street(#PCDATA)>
<!ELEMENT city(#PCDATA)>
<!ELEMENT email(#PCDATA)>
<!ELEMENT phno(#PCDATA)>
student.xsd:
<xs:schema>
<xs:element name="student">
<xs:complextype>
<xs:sequence>
<xs:element name="roll_no" type="xs:string"/>
<xs:element name="name">
<xs:complextype>
<xs:sequence>
<xs:element name="first_name" type="xs:string"/>
<xs:element name="last_name" type="xs:string"/>
</xs:sequence>
</xs:complextype>
</xs:element>
<xs:element name="father-name">
<xs:complextype>
<xs:sequence>
<xs:element name="first_name" type="xs:string"/>
<xs:element name="last_name" type="xs:string"/>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 33 of 72
</xs:sequence>
</xs:complextype>
</xs:element>
<xs:element name="branch" type="xs:string"/>
<xs:element name="year" type="xs:integer"/>
<xs:element name="addr">
<xs:complextype>
<xs:sequence>
<xs:element name="door-no" type="xs:string"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
</xs:sequence>
</xs:complextype>
</xs:element>
<xs:element name="email" type="xs:string"/>
<xs:element name="phno" type="xs:integer"/>
</xs:sequence>
</xs:complextype>
</xs:element>
</xs:schema>
student.xml:
<?xml version="1.0" ?>
- <student xmlns:xsi="xmlschema-instance" xsi:SchemaLocation="student.xsd">
<roll_no>08A01D2501</roll_no>
- <name>
<first_name>A</first_name>
<Last_name>Aruna</Last_name>
</name>
- <father_name>
<first_name>Venkateswara</first_name>
<Last_name>Rao</Last_name>
</father_name>
<branch>computer engineering</branch>
<year>1ST Year</year>
- <address>
<door-no>32-15/1-44</door-no>
<street>B.R.Nagar-1</street>
<city>Gurgaon</city>
</address>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 34 of 72
<email>[email protected]</email>
<phno>9949643372</phno>
<roll_no>08A01D2501</roll_no>
- <name>
<first_name>Prathap</first_name>
<Last_name>Rudra</Last_name>
</name>
- <father_name>
<first_name>Venkateswara </first_name>
<Last_name>B</Last_name>
</father_name>
<branch> computer engineering (mtech) </branch>
<year>1st Year</year>
- <address>
<door-no>door no 603/n</door-no>
<street>Recoloney</street>
<city>Delhi</city>
</address>
<email>[email protected]</email>
<phno>9866145423</phno>
<roll_no>08A01D2503</roll_no>
- <name>
<first_name>Ramesh</first_name>
<Last_name>Kumar</Last_name>
</name>
- <father_name>
<first_name>Venkateswara</first_name>
<Last_name>Rao</Last_name>
</father_name>
<branch> computer engineering(mtech) </branch>
<year>1st Year</year>
- <address>
<door-no>32-15/1-44</door-no>
<street>B.R.Nagar-1</street>
<city>Gurgaon</city>
</address>
<email>[email protected]</email>
<phno>9985150379</phno>
<roll_no>08A01D2504</roll_no>
- <name>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 35 of 72
<first_name>kishore</first_name>
<Last_name>Galla</Last_name>
</name>
- <father_name>
<first_name>Venkateswara</first_name>
<Last_name>Rao</Last_name>
</father_name>
<branch> Computer engineering (mtech) </branch>
<year>1st Year</year>
- <address>
<door-no>32-15/1-44</door-no>
<street>B.R.Nagar-1</street>
<city>Gurgaon</city>
</address>
<email>[email protected]</email>
<phno>990837394</phno>
<roll_no>08A01D2505</roll_no>
- <name>
<first_name>Madhu</first_name>
<Last_name>Garlapati</Last_name>
</name>
- <father_name>
<first_name>Venkateswara</first_name>
<Last_name>Rao</Last_name>
</father_name>
<branch> commputer engineering (mtech) </branch>
<year>1st Year</year>
- <address>
<door-no>32-15/1-44</door-no>
<street>B.R.Nagar-1</street>
<city>Gurgaon</city>
</address>
<email>[email protected]</email>
<phno>9908005778</phno>
</student>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 36 of 72
4. Install TOMCAT web server. Convert the static web pages of assignments 2 into dynamic web
Pages using Servlets and cookies. Hint: Users information (user id, password, credit card
number) would be stored in web.xml. Each user should have a separate Shopping Cart.
Step 1
Step 2
bin folder
logs folder
webapps folder
work folder
temp folder
conf folder
lib folder
Step 3
We need to create an environment variable called "JAVA_HOME" and set it to our JDK installed
directory.
1. To create the JAVA_HOME environment variable in Windows XP/Vista/7 we need to push the
"Start" button then select "Control Panel" / "System" / "Advanced system settings". Then switch
to the "Advanced" tab and select "Environment Variables" / "System Variables" then
select "New" (or "Edit" for modification). In "Variable Name", enter "JAVA_HOME". In
"Variable Value", enter your JDK installed directory (e.g., "c:\Program
Files\Java\jdk1.7.0_{xx}").
2. For ensuring that it is set correctly, we need to start a command shell (to refresh the
environment) and issue:
set JAVA_HOME
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 37 of 72
Step 4
The configuration files of the Apache Tomcat Server are located in the "conf" sub-directory of our
Tomcat installed directory, for example "E:\myserver\tomcat7.0.40\conf". There are 4 configuration
XML files:
1. context.xml file
2. tomcat-users.xml file
3. server.xml file
4. web.xml file
Open the configuration file "web.xml". We shall enable the directory listing by changing "listings" from
"false" to "true" for the "default" servlet.
<param-value>true</param-value> like:
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 38 of 72
The default port number of Tomcat is 8080. Now we need to change the TCP port number for Tomcat,
since the same port number can be used by other servers like SQL Server. We may choose any number
between 1024 and 65535. We shall choose 9999 in this article.
In that we set reloadable="true" to the <Context> element to enable automatic reload after code changes.
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 39 of 72
<Context reloadable="true">
......
</Context> Like
It is used to manage Tomcat by adding the highlighted lines, inside the <tomcat-users> elements.
Step 5
Executable programs and scripts are kept in the "bin" sub-directory of the Tomcat installed directory,
e.g., "E:\myserver\tomcat7.0.40\bin".
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 40 of 72
After that a new Tomcat console window appears. Read the messages on the console. Look out for the
Tomcat's port number (double check that Tomcat is running on port 9999).......
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 41 of 72
Now try the URL http://localhost:9999/examples to view JSP and servlet examples.
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 42 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 43 of 72
Web.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Servlet 2.4 Examples</display-name>
<description> Servlet 2.4 Examples. </description>
<servlet>
<servlet-name>reg</servlet-name>
<servlet-class>reg</servlet-class>
</servlet>
<servlet>
<servlet-name>login</servlet-name>
<servlet-class>login</servlet-class>
</servlet>
<servlet>
<servlet-name>profile</servlet-name>
<servlet-class>profile</servlet-class>
</servlet>
<servlet>
<servlet-name>catalog</servlet-name>
<servlet-class>catalog</servlet-class>
<servlet-mapping>
<servlet-name>order</servlet-name>
<url-pattern>
</servlet>
<servlet>
<servlet-name>order</servlet-name>
<servlet-class>order</servlet-class>
</servlet>
<url-pattern>order</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>catalog</servlet-name>
<url-pattern>catalog</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>profile</servlet-name>
<url-pattern>profile</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>login</servlet-name>
<url-pattern>login</url-pattern>
</servlet-mapping>
<servlet-mapping> <servlet-name>reg</servlet-name> <url-pattern>reg</url-pattern>
</servlet-mapping></web-app>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 44 of 72
Main.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body bgcolor="pink">
<br /><br /><br /><br /><br />
<h1 align="center"><U>ONLINE BOOK STORAGE</U></h1><br /><br /><br />
<h2 align="center"><pre>
<b>Welcome to online book storage.
Press LOGIN if you are having id
otherwise press REGISTRATION
</b></pre></h2>
<br /><br /><pre>
<div align="center"><a href="/tr/login.html">LOGIN</a> <a href="/tr/reg.html">
REGISTRATION</a></div></pre>
</body>
</html>
Login.html
<html>
<body bgcolor="pink"><br /><br /><br />
<form name="myform" method="post" action="/tr/login">
<div align="center"><pre>
LOGIN ID :<input type="text" name="id" /><br />
PASSWORD :<input type="password" name="pwd" /></pre><br /><br />
</div>
<br /><br />
<div align="center">
<input type="submit" value="ok" onclick="validate()" />
<input type="reset" value="clear" />
</div>
</form>
</body>
</html>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 45 of 72
Reg.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body bgcolor="pink"><br /><br />
<form name="myform" method="post" action="/tr/reg">
<div align="center"><pre>
NAME :<input type="text" name="name" /><br />
ADDRESS :<input type="text" name="addr" /><br />
CONTACT NUMBER :<input type="text" name="phno" /><br />
LOGINID :<input type="text" name="id" /><br />
PASSWORD :<input type="password" name="pwd" /></pre><br /><br />
</div>
<br /><br />
<div align="center">
<input type="submit" value="ok" onclick="validate()" />
<input type="reset" value="clear" />
</div>
</form>
</body>
</html>
Profile.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body bgcolor="pink"><br /><br /><br />
<form name="myform" method="post" action="/tr/profile">
<div align="center"><pre>
LOGIN ID :<input type="text" name="id" /><br />
</pre><br /><br />
</div>
<br /><br />
<div align="center">
<input type="submit" value="ok" onclick="validate()" />
<input type="reset" value="clear" />
</div>
</form>
</body>
</html>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 46 of 72
Catalog.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body bgcolor="pink"><br /><br /><br />
<form method="post" action="/tr/catalog">
<div align="center"><pre>
BOOK TITLE :<input type="text" name="title" /><br />
</pre><br /><br />
</div>
<br /><br />
<div align="center">
<input type="submit" value="ok"
name="button1"/>
<input type="reset" value="clear" name="button2"/>
</div>
</form>
</body>
</html>
Order.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body bgcolor="pink"><br /><br />
<form method="post" action="/tr/reg">
<div align="center"><pre>
NAME :<input type="text" name="name" /><br />
PASSWORD :<input type="password" name="pwd" />
TITLE :<input type="text" name="title" /><br />
NO. OF BOOKS :<input type="text" name="no" /><br />
DATE :<input type="text" name="date" /><br />
CREDIT CARD NUMBER:<input type="password" name="cno" /><br
/></pre><br /><br />
</div>
<br /><br />
<div align="center">
<input type="submit" value="ok" name="button1"/>
<input type="reset" value="clear"
name="button2"/>
</div>
</form>
</body>
</html>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 47 of 72
Login.java
import java.sql.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class login extends HttpServlet{
public void service(HttpServletRequest req,HttpServletResponse resp)
throws ServletException,IOException {
PrintWriter pw=resp.getWriter();
pw.println("<html><body bgcolor=\"pink\");
String id=req.getParamenter("id");
String pwd=req.getParameter("pwd");
try {
Driver d=new oracle.jdbc.driver.OracleDriver();
DriverManager.registerDriver(d);
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger");
Statement stmt=con.createStatement();
String sqlstmt="select id,password from login";
ResultSet rs=stmt.executeQuery(sqlstmt);
int flag=0;
while(rs.next()) {
if(id.equal(rs.getString(1))&&pwd.equals(rs.getString(2))) {
flag=1;
}
}
if(flag==0) {
pw.println("SORRY INVALID ID TRY AGAIN ID<br><br>");
pw.println("<a href=\"/tr/login.html\">press LOGIN to RETRY</a>");
}
else {
pw.println("VALID LOGIN ID<br><br>");
pw.println("<h3><ul>");
pw.println("<li><ahref=\"profile.html\"><fontcolor=\"black\">USER
PROFILE</font> </a></li><br><br>");
pw.println("<li><ahref=\"catalog.html\"><fontcolor=\"black\">BOOKS
CATALOG</font></a></li><br><br>");
pw.println("<li><ahref=\"order.html\"><fontcolor=\"black\">ORDER
CONFIRMATION</font> </a></li><br><br>");
}
pw.println("</body></html>");
}
catch(Exception e) { resp.sendError(500,e.toString());
}
}
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 48 of 72
Reg.html
import java.sql.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class login extends HttpServlet{
public void service(HttpServletRequest req,HttpServletResponse resp)
throws ServletException,IOException {
PrintWriter pw=resp.getWriter();
pw.println("<html><body bgcolor=\"pink\");
String name=req.getParamenter("name");
String addr=req.getParameter("addr");
String phno=req.getParameter("phno");
String id=req.getParamenter("id");
String pwd=req.getParameter("pwd");
int no=Integer.parseInt(phno);
try {
Driver d=new oracle.jdbc.driver.OracleDriver();
DriverManager.registerDriver(d);
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger");
Statement stmt=con.createStatement();
String sqlstmt="select id,password from login";
ResultSet rs=stmt.executeQuery(sqlstmt);
int flag=0;
while(rs.next()) {
if(id.equal(rs.getString(1))&&pwd.equals(rs.getString(2))) {
flag=1;
}}
if(flag==1) {
pw.println("SORRY INVALID ID ALREADY EXITS TRY AGAIN WITH NEW
ID<br><br>");
pw.println("<a href=\"/tr/reg.html\">press REGISTER to RETRY</a>");
}
else {
Statement stmt1=con.createStatement();
stmt1.executeUpdate("insertintologin
values("+names","+addr+","+no+","+id+","+pwd+")");
pw.println("YOUR DETAILS ARE ENTERED<br><br>");
pw.println("<a href=\"/tr/login.html\">press LOGIN to login</a>");
}
pw.println("</body></html>");
}
catch(Exception e) { resp.sendError(500,e.toString());
} }}
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 49 of 72
Catlog.java
import java.sql.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class login extends HttpServlet{
public void service(HttpServletRequest req,HttpServletResponse resp)
throws ServletException,IOException {
PrintWriter pw=resp.getWriter();
pw.println("<html><body bgcolor=\"pink\");
String title=req.getParameter("title");
try {
Driver d=new oracle.jdbc.driver.OracleDriver();
DriverManager.registerDriver(d);
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger");
Statement stmt=con.createStatement();
String sqlstmt="select id,password from login";
ResultSet rs=stmt.executeQuery(sqlstmt);
int flag=0;
while(rs.next()) {
pw.println(",div align=\"center\">");
pw.println("TITLE :"+rs.getString(1)+"<br>");
pw.println("AUTHOR :"+rs.getString(2)+"<br>");
pw.println("VERSION :"+rs.getString(3)+"<br>");
pw.println("PUBLISHER :"+rs.getString(4)+"<br>");
pw.println("COST :"+rs.getString(5)+"<br>");
pw.println("</div");
flag=1;
}
if(flag==0) {
pw.println("SORRY INVALID TITLE TRY AGAIN <br><br>");
pw.println("<a href=\"/tr/catalog.html\">press HERE to RETRY</a>");
}
pw.println("</body></html>");
}
catch(Exception e) {
resp.sendError(500,e.toString());
}
}
}
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 50 of 72
Profile.java
import java.sql.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class login extends HttpServlet{
public void service(HttpServletRequest req,HttpServletResponse resp)
throws ServletException,IOException {
PrintWriter pw=resp.getWriter();
pw.println("<html><body bgcolor=\"pink\");
String id=req.getParamenter("id");
try {
Driver d=new oracle.jdbc.driver.OracleDriver();
DriverManager.registerDriver(d);
Connection con=DriverManager.getConnection("jdbc:oracle:thin:
@localhost:1521:orcl","scott","tiger");
Statement stmt=con.createStatement();
String sqlstmt="select * from login where id="+id+"";
ResultSet rs=stmt.executeQuery(sqlstmt);
int flag=0;
pw.println("<br><br><br>");
while(rs.next()) {
pw.println("<div align=\"center\">");
pw.println("NAME :"+rs.getString(1)+"<br>");
pw.println("ADDRESS :"+rs.getString(2)+"<br>");
pw.println("PHONE NO :"+rs.getString(3)+"<br>");
pw.println("</div>");
flag=1;
}
if(flag==0) {
pw.println("SORRY INVALID ID TRY AGAIN ID<br><br>");
pw.println("<a href=\"/tr/profile.html\">press HERE to RETRY</a>");
}
pw.println("</body></html>");
}
catch(Exception e) {
resp.sendError(500,e.toString());
}
}
}
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 51 of 72
Order.java
import java.sql.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class login extends HttpServlet{
public void service(HttpServletRequest req,HttpServletResponse resp)
throws ServletException,IOException {
PrintWriter pw=resp.getWriter();
pw.println("<html><body bgcolor=\"pink\");
String id=req.getParamenter("id");
String pwd=req.getParameter("pwd");
String title=req.getParameter("title");
String count1=req.getParameter("no");
String date=req.getParameter("date");
String cno=req.getParameter("cno");
int count=Integer.parseInt(count1);
try {
Driver d=new oracle.jdbc.driver.OracleDriver();
DriverManager.registerDriver(d);
Connection
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger")
;
Statement stmt=con.createStatement();
String sqlstmt="select id,password from login";
ResultSet rs=stmt.executeQuery(sqlstmt);
int flag=0,amount,x;
while(rs.next()) {
if(id.equals(rs.getString(1))&&pwd.equals(rs.getString(2))) {
flag=1;
}
}
if(flag==0) {
pw.println("SORRY INVALID ID TRY AGAIN ID<br><br>");
pw.println("<a href=\\"/tr/order.html\\">press HERE to RETRY</a>");
}
else {
Statement stmt2=con.createStatement();
String s="select cost from book where title="+title+"";
ResultSet rs1=stmt2.executeQuery(s);
int flag1=0;
while(rs1.next()) {
flag1=1;
x=Integer.parseInt(rs1.getString(1));
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 52 of 72
amount=count*x;
pw.println("AMOUNT :"+amount+"<br><br><br><br>");
Statement stmt1=con.createStatement();
stmt1.executeUpdate("insertintodetails
values('"+id+",'"+title+"'+amount+'","'+cno+'")"');
pw.println("YOUR ORDER has taken<br>");
}
if(flag1==0) {
pw.println("SORRY INVALID ID TRY AGAIN ID<br><br>");
pw.println("<a href=\\"/tr/order.html\\">press HERE to RETRY</a>");
}
}
pw.println("</body></html>");
con.close();
}
catch(Exception e) {
resp.sendError(500,e.toString());
}
}
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 53 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 54 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 55 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 56 of 72
5. Redo the previous task using JSP by converting the static web pages of assignments 2 into
dynamic webpages. Create a database with user information and books information and books
information. The books catalogue should be dynamically loaded from the database. Follow the
MVC architecture while doing the website.
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 57 of 72
Login.html:
<html>
<body bgcolor=”pink”><br><br><br>
<form name="myform" method="post" action=/tr1/login.jsp">
<div align="center"><pre>
LOGIN ID : <input type="passwors" name="pwd"></pre><br><br>
PASSWORD : <input type="password" name="pwd"></pre><br><br>
</div>
<br><br>
<div align="center">
<inputtype="submit"value="ok" onClick="validate()"> <input
type="reset"
value="clear">
</form>
</body>
</html>
Reg.html:
<html>
<body bgcolor="pink"><br><br>
<form name="myform" method="post" action="/tr1/reg.jsp">
<div align="center"><pre>
NAME :<input type="text" name="name"><br>
ADDRESS :<input type="text" name="addr"><br>
CONTACT NUMBER : <input type="text" name="phno"><br>
LOGIN ID : <input type="text" name="id"><br>
PASSWORD : <input type="password" name="pwd"></pre><br><br>
</div>
<br><br>
<div align="center">
<inputtype="submit"value="ok"
onClick="validate()">()"> <input type="reset"
value="clear">
</form>
</body>
</html>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 58 of 72
Profile.html:
<html>
<body bgcolor="pink"><br><br>
<form name="myform" method="post" action="/tr1/profile.jsp">
<div align="center"><pre>
LOGIN ID : <input type="text" name="id"><br>
</pre><br><br>
</div>
<br><br>
<div align="center">
<inputtype="submit"value="ok"
onClick="validate()">()"> <input type="reset"
value="clear">
</form>
</body>
</html>
Catalog.html:
<html>
<body bgcolor="pink"><br><br><br>
<form method="post" action="/tr1/catalog.jsp">
<div align="center"><pre>
BOOK TITLE : <input type="text" name="title"><br>
</pre><br><br>
</div>
<br><br>
<div align="center">
<inputtype="submit"value="ok"
name=”button1”> <inputtype="reset"value="clear" name=”butt
on2”>
</form>
</body>
</html>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 59 of 72
Order.html:
<html>
<body bgcolor="pink"><br><br><br>
<form method="post" action="/tr1/order.jsp">
<div align="center"><pre>
LOGIN ID :<input type="text" name="id"><br>
PASSWORD : <input type="password" name="pwd"><br>
TITLE :<input type="text" name="title"><br>
NO. OF BOOKS : <input type="text" name="no"><br>
DATE : <input type="text" name="date"><br>
CREDIT CARD NUMBER : <input type="password" name="cno"><br></pre><br><br>
</div>
<br><br>
<div align="center">
<input type="submit" value="ok" name=”button1”> <input
type="reset"
value="clear" name=”button2”>
</form>
</body>
</html>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 60 of 72
Login.jsp:
%@page import=”java.sql.*”%
%@page import=”java.io.*”%
<%
out.println(“<html><body bgcolor=\”pink\”>”);
String id=request.getParameter(“id”);
String pwd=request.getParameter(“pwd”);
Driver d=new oracle.jdbc.driver.OracleDriver();
DriverManager.registerDriver(d);
Connection
con=DriverManager.getConnection(“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”);
Statement stmt=con.createStatement();
String sqlstmt=”select id,password from login where id=”+id+” and password=”+pwd+””;
ResultSet rs=stmt.executeQuery(sqlstmt);
int flag=0;
while(rs.next())
{
flag=1;
}
if(flag==0)
{
out.println(“SORRY INVALID ID TRY AGAIN ID<br><br>”);
out.println(“ <a href=\”/tr1/login.html\”>press LOGIN to RETRY</a>”);
}
else
{
out.println(“VALID LOGIN ID<br><br>”);
out.println(“<h3><ul>”);
out.println(“<li><ahref=\”profile.html\”><fontcolor=\”black\”>USER
PROFILE</font></a></li><br><br>”);
out.println(“<li><ahref=\”catalog.html\”><fontcolor=\”black\”>BOOKS
CATALOG</font></a></li><br><br>”);
out.println(“<li><ahref=\”order.html\”><fontcolor=\”black\”>ORDER
CONFIRMATION</font></a></li><br><br>”);
out.println(“</ul>”);
}
out.println(“<body></html>”);
%>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 61 of 72
Reg.jsp:
%@page import=”java.sql.*”%
%@page import=”java.io.*”%
<%
out.println(“<html><body bgcolor=\”pink\”>”);
String name=request.getParameter(“name”);
String addr=request.getParameter(“addr”);
String phno=request.getParameter(“phno”);
String id=request.getParameter(“id”);
String pwd=request.getParameter(“pwd”);
int no=Integer.parseInt(phno);
Driver d=new oracle.jdbc.driver.OracleDriver();
DriverManager.registerDriver(d);
Connection con=
DriverManager.getConnection (“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”);
Statement stmt=con.createStatement();
String sqlstmt=”select id from login”;
ResultSet rs=stmt.executeQuery(sqlstmt);
int flag=0;
while(rs.next())
{
if(id.equals(rs.getString(1)))
{
flag=1;
}
}
if(flag==1)
{
out.println(“SORRY LOGIN ID ALREADY EXISTS TRY AGAIN WITH NEW ID
<br><br>”);
out.println(“<a href=\”/tr1/reg.html\”>press REGISTER to RETRY</a>”);
}
else
{
Statement stmt1=con.createStatement ();
stmt1.executeUpdate (“insert into login values (“+name+”,”+addr+”,”+no+”,”+id+”,”+pwd+”)”);
out.println (“YOU DETAILS ARE ENTERED <br><br>”);
out.println (“<a href =\”/tr1/login.html\”>press LOGIN to login</a>”);
} out.println (“</body></html>”);%>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 62 of 72
Profile.jsp:
<%@page import=”java.sql.*”%>
<%@page import=”java.io.*”%>
<%
out.println (“<html><body bgcolor=\”pink\”>”);
String id=request.getParameter(“id”);
Driver d=new oracle.jdbc.driver.OracleDriver();
DriverManager.regiserDriver(d);
Connection con=
DriverManager.getConnection (“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”);
Statement stmt=con.createStatement ();
String sqlstmt=”select * from login where id=”+id+””;
ResultSet rs=stmt.executeQuery (sqlstmt);
int flag=0;
while(rs.next())
{
out.println (“<div align=\”center\”>”);
out.println (“NAME :”+rs.getString(1)+”<br>”);
out.println (“ADDRESS :”+rs.getString(2)+”<br>”);
out.println (“PHONE NO :”+rs.getString(3)+”<br>”);
out.println (“</div>”);
flag=1;
}
if(flag==0)
{
out.println(“SORRY INVALID ID TRY AGAIN ID <br><br>”);
out.println(“<a href=\”/tr1/profile.html\”>press HERE to RETRY </a>”);
}
out.println (“</body></html>”);
%>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 63 of 72
Catalog.jsp:
<%@page import=”java.sql.*”%>
<%@page import=”java.io.*”%>
<%
out.println (“<html><body bgcolor=\”pink\”>”);
String title=request.getParameter (“title”);
Driver d=new oracle.jdbc.driver.OracleDriver ();
DriverManager.regiserDriver (d);
Connection con=
DriverManager.getConnection (“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”);
Statement stmt=con.createStatement ();
String sqlstmt=”select * from book where title=”+title+””;
ResultSet rs=stmt.executeQuery (sqlstmt);
int flag=0;
while(rs.next())
{
out.println (“<div align=\”center\”>”);
out.println (“TITLE :”+rs.getString(1)+”<br>”);
out.println (“AUTHOR :”+rs.getString(2)+”<br>”);
out.println (“VERSION:”+rs.getString(3)+”<br>”);
out.println (“PUBLISHER :” +rs.getString(4)+”<br>”);
out.println (“COST :” +rs.getString(5)+”<br>”);
out.println (“</div>”);
flag=1;
}
if(flag==0)
{
out.println(“SORRY INVALID ID TRY AGAIN ID <br><br>”);
out.println(“<a href=\”/tr1/catalog.html\”>press HERE to RETRY </a>”);
}
out.println (“</body></html>”);
%>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 64 of 72
Order.jsp:
<%@page import=”java.sql.*”%>
<%@page import=”java.io.*”%>
<%
out.println (“<html><body bgcolor=\”pink\”>”);
String id=request.getParameter (“id”);
String pwd=request.getParameter (“pwd”);
String title=request.getParameter (“title”);
String count1=request.getParameter (“no”);
String date=request.getParameter (“date”);
String cno=request.getParameter (“cno”);
int count=Integer.parseInt(count1);
Driver d=new oracle.jdbc.driver.OracleDriver ();
DriverManager.regiserDriver (d);
Connection con=
DriverManager.getConnection (“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”);
Statement stmt=con.createStatement ();
String sqlstmt=”select id, password from login”;
ResultSet rs=stmt.executeQuery (sqlstmt);
int flag=0,amount,x;
while(rs.next())
{
if(id.equals(rs.getString(1))&& pwd.equals(rs.getString(2)))
{
flag=1;
}
}
if(flag==0)
{
out.println(“SORRY INVALID ID TRY AGAIN ID <br><br>”);
out.println(“<a href=\”/tr1/order.html\”>press HERE to RETRY </a>”);
}
else
{
Statement stmt2=con.createStatement();
String s=”select cost from book where title=”+title+””;
ResultSet rs1=stmt2.executeQuery(s);
int flag1=0;
while(rs1.next())
{
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 65 of 72
flag1=1;
x=Integer.parseInt(rs1.getString(1));
amount=count*x;
out.println(“AMOUNT :”+amount+”<br><br><br><br>”);
Statement stmt1=con.createStatement ();
stmt1.executeUpdate (“insert into details (“+id+”,”+title+”,”+amount+”,”+date+”,”+cno+”)”);
out.println (“YOU ORDER HAS TAKEN<br>”);
}
if(flag1==0)
{
out.println(“SORRY INVALID BOOK TRY AGAIN <br><br>”);
out.println(“<a href=\”/tr1/order.html\”>press HERE to RETRY </a>”);
}
} out.println (“</body></html>”);%>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 66 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 67 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 68 of 72
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 69 of 72
ActionOne.java:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class ActionOne extends Action
{
publicActionForwardexecute(ActionMappingmapping,ActionFormform,HttpServletRequest
request,HttpServletResponse response)throws Exception
{
System.out.println("‐‐‐Action executed‐‐‐‐");
PrintWriter pw=response.getWriter();
pw.println("HELLO WORLD!");
return null;
}
}
Step 3:
Struts‐Config.xml file
<?xml version="1.0" encoding="UTF‐8"?>
<struts‐config>
<action‐mappings>
<action path="/xxx" type="ActionOne"/>
</action‐mappings>
</struts‐config>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 70 of 72
Step 4:
Web.xml
<?xml version="1.0" encoding="ISO‐8859‐1"?>
<web‐app>
<servlet>
<servlet‐name>action</servlet‐name>
<servlet‐class>org.apache.struts.action.ActionServlet</servlet‐class>
<init‐‐param>
<param‐name>config</param‐name>
<param‐value>/WEB‐INF/struts‐config.xml</param‐value>
</init‐param>
<init‐param>
<param‐name>debug</param‐name>
<param‐value>2</param‐value>
</init‐param>
<load‐on‐startup>2</load‐on‐startup>
</servlet>
<!‐‐Standard Action Servlet Mapping ‐‐>
<servlet‐mapping>
<servlet‐name>action</servlet‐name>
<url‐pattern>*.do</url‐pattern>
</servlet‐mapping>
<!‐‐ The Usual Welcome File List ‐‐>
<welcome‐file‐list>
<welcome‐file>index.jsp</welcome‐file>
</welcome‐file‐list>
<!‐‐ Struts Tag Library Descriptors ‐‐>
<taglib>
<taglib‐uri>/tags/struts‐bean</taglib‐uri>
<taglib‐location>/WEB‐INF/struts‐html.tld</taglib‐location>
</taglib>
<taglib>
<taglib‐uri>/tags/struts‐logic</taglib‐uri>
<taglib‐location>/WEB‐INF/struts‐logic.tld</taglib‐location>
</taglib>
<taglib>
<taglib‐uri>/tags/struts‐nested</taglib‐uri>
<taglib‐location>/WEB‐INF/struts‐nested.tld</taglib‐location>
</taglib>
<taglib>
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com
Page 71 of 72
<taglib‐uri>/tags/struts‐tiles</taglib‐uri>
<taglib‐location>/WEB‐INF/struts‐tiles.tld</taglib‐location>
</taglib>
</web‐app>
Step 5:
Then in I.E give the url as http:localhost:8080/ts/xxx.do
For study materials, lab manuals, Lecture Presentations, Video lectures, seminar topics & projects visit
www.btechsmartclass.com