0% found this document useful (0 votes)
111 views

All Programs WT

The document describes the design of static web pages for an online book store website including home, login, catalogue, registration and cart pages. The home page contains three frames - top frame with logo and links, left frame with department links, and right frame to display page content. The login page contains username and password fields. The catalogue page displays book details in a table with images, prices and add to cart buttons. The registration page contains a form to collect user information like name, password, email, gender, date of birth, languages known, address and mobile number. The cart page displays ordered books details with book name, price, quantity and total amount.

Uploaded by

soumya moturi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views

All Programs WT

The document describes the design of static web pages for an online book store website including home, login, catalogue, registration and cart pages. The home page contains three frames - top frame with logo and links, left frame with department links, and right frame to display page content. The login page contains username and password fields. The catalogue page displays book details in a table with images, prices and add to cart buttons. The registration page contains a form to collect user information like name, password, email, gender, date of birth, languages known, address and mobile number. The cart page displays ordered books details with book name, price, quantity and total amount.

Uploaded by

soumya moturi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 71

EXP NO: 1

AIM: Design the following static web pages required for an online book store web site.

i. Home Page ii. Login Page iii. Catalogue Page

1) HOME PAGE:
The static home page must contain three frames.

Top frame : Logo and the college name and links to Home page, Login page, Registration page,
Catalogue page and Cart page (the description of these pages will be given below).
Left frame : At least four links for navigation, which will display the catalogue of respective links.
For e.g.: When you click the link “CSE” the catalogue for CSE Books should be displayed in the Right
frame.
Right frame: The pages to the links in the left frame must be loaded here. Initially this page contains
description of the web site.

Web Site Name


Logo
Home Login Registration Catalogue Cart

CSE
ECE Description of the Web Site
EEE
CIVIL

Fig 1.1
2) LOGIN PAGE:

This page looks like below:


Web Site Name
Logo
Home Login Registration Catalogue Cart
CSE
ECE Login :
EEE Password:
CIVIL

Submit Reset

3) CATOLOGUE PAGE:
The catalogue page should contain the details of all the books available in the web site in a table.
The details should contain the following:

1. Snap shot of Cover Page.


2. Author Name.
3. Publisher.
4. Price.
5. Add to cart button.

Web Site Name


Logo
Home Login Registration Catalogue Cart

CSE Book : XML Bible


Author : Winston $ 40.5
ECE Publication : Wiely

EEE
Book : AI $ 63
CIVIL Author : S.Russel
Publication :
Princeton hall

Book : Java 2 $ 35.5


Author : Watson
Publication : BPB
publications

Book : HTML in 24 $ 50
hours
Author : Sam Peter
Publication : Sam
publication

Source Code
Index.html
<frameset rows="200px,*">
<frame src="top.html" />
<frameset cols="150px,*">
<frame src="left.html" />
<frame src="home.html" name="body" id="body" />
</frameset>
</frameset>

Top.html
<html>
<head>
<title>Top Page</title>
</head>
<body>
<table width="100%">
<tr><td><img src="images/logo.jpg" alt="logo" /></td><td
colspan="4"><h1>ONLINE BOOK STORE </h1></td>
</tr><tr><td><br><br></td></tr>
<tr ><td><a href="home.html" target="body">HOME</a></td>
<td><a href="login.html" target="body">Login</a></td><td><a
href="registration.html" target="body">Registration</a></td>
<td><a href="catalogue.html" target="body">Catalogue</a></td>
<td><a href="cart.html" target="body">Cart</a></td>
</tr>
</table>
</body>
</html>

Left.html

<html>
<head>
<title>Top Page</title>
</head>

<body>
<a href="cse.html" target="body">CSE</a><br />
<a href="ece.html" target="body">ECE</a><br />
<a href="eee.html" target="body">EEE</a><br />
<a href="civil.html" target="body">CIVIL</a><br />
</body>
</html>

Login.html
<html>
<head>
<title>Login Page</title>
</head>
<body>
Username: <input name="uname" type="text" /><br />
Password: <input type="text" name="password" /><br />
<input type="submit" value="Submit" />&nbsp;&nbsp;<input type="reset" value="Reset" />
</body>
</html>

Catalogue.html
<html>
<head>
<title>Catalogue Page</title>
</head>
<body>
<table>
<tr><td><img src="images/xml.jpg" /><br /><br /></td>
<td>Book : XML Bible<br />Author : Winston<br />Publication : Wiely<br /></td>
<td>$ 40.5</td>
<td><input type="image" src="images/cart.jpg" /></td></tr>
<tr><td><img src="images/ai.jpg" /><br /><br /></td>
<td>Book : AI<br />Author : S.Russel<br />Publication : Princeton hall</td><td>$
63</td><td><input type="image" src="images/cart.jpg" /></td></tr>
<tr><td><img src="images/java.jpg" /><br /><br /></td>
<td>Book : Java 2<br />Author : Watson<br />Publication : BPB publications</td>
<td>$ 35.5</td><td><input type="image" src="images/cart.jpg" /></td></tr>
<tr><td><img src="images/html.jpg" /><br /><br /></td>
<td>Book : HTML in 24 hours<br />Author : Sam Peter<br />Publication : Sam
publication</td>
<td>$ 50</td><td><input type="image" src="images/cart.jpg" /></td></tr>
</table>
</body>
</html>

Home.html
<html>
<head>
<title>Home Page</title>
</head>
Description of Online Book Store
</body>
</html>

Execution Procedure
Step1: type all html programs in notepad or any text editor and save .html format.
Step2: open web browser and open index.html
Step3: traverse all pages from index.html.
EXP NO: 2
Aim: Design the following static web pages required for an online book store web site.
i. Registration Page ii. Cart Page

CART PAGE:
The cart page contains the details about the books which are added to the cart.

5) REGISTRATION PAGE:

Create a “registration form “with the following fields

1) Name (Text field)


2) Password (password field)
3) E-mail id (text field)
4) Phone number (text field)
5) Sex (radio button)
6) Date of birth (3 select boxes)
7) Languages known (check boxes – English, Telugu, Hindi, Tamil)
8) Address (text area)

Description
Through table and form tag we can design pages.
The form tag you can add to your web pages a guestbook, order forms, surveys, get feedback or
whatever. The basic construction of a html form is this...
<FORM> begin a form
<INPUT> ask for information in one of several different ways...
<INPUT> ...there can be as many input areas as you wish
</FORM> end a form
<TABLE>
The main tag. Used to tell the browser "this is a table", along with some attributes like size,
border width and a few other things.
<TR>
TableRow defines a horizontal row of <TD> (TableData) cells.
<TD>
Specifies an indiviual block or cell in a table row

Source Code

Registraion.html
<HTML>
<HEAD>
</HEAD>
<BODY bgcolor='#999900'>
<form name='register' action='register.jsp' onsubmit="return validate(this);">
<table align='center' cellspacing='20'>
<tr>
<td>Enter Name</td>
<td><input type='text' name="name"></td>
</tr>
<tr>
<td>Enter Password</td>
<td><input type='password' name="password"></td>
</tr>
<tr>
<td>Enter Email</td>
<td><input type='text' name="email"></td>
</tr>
<tr>
<td>Select Gender</td>
<td>
Male<input type='radio' name="gender" value='male'>
Female<input type='radio' name="gender" value='female'>
Other<input type='radio' name="gender" value='other'>
</td>
</tr>
<tr>
<td>Date of birth</td>
<td>
<select name='date'>
<option value='---date----'>date</option>
<script>
for(i=1;i<=31;i++)
document.write("<option value="+i+">"+i+"</option>")
</script>
</select>
<select name='month'>
<option value='---month---'>month</option>
<script>
for(i=1;i<=12;i++)
document.write("<option value="+i+">"+i+"</option>")
</script>
</select>
<select name="year">
<option value='---year---'>year</option>
<script>
for(i=1900;i<=2100;i++)
document.write("<option value="+i+">"+i+"</option>")
</script>
</select>
</td>
</tr>
<tr>
<td>Languages Known</td>
<td>
Telugu<input type='checkbox' name='telugu' value='telugu'>
Hindhi<input type='checkbox' name='hindhi' value='hidhi'>
Tamil<input type='checkbox' name='tamil' value='tamil'>
English<input type='checkbox' name='english' value='english'>
</td>
</tr>
<tr>
<td>Address</td>
<td><textarea name='address' rows='5' cols='25'></textarea></td>
</tr>
<tr>
<td>Mobile Number</td>
<td><input type="text" name="mobile"></td>
</tr>
<tr>
<td>
<input type='submit' value='Register'>
</td>
<td>
<input type='reset' value='Clear'>
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
Output:
Cart.html
<html>
<head>

<title>Cart Page</title>
</head>
<body>
<table ><tr><th>Book name</th><th>Price</th><th>Quantity</th><th>Amount</th></tr>
<tr><td>Java 2</td><td>$35.5</td><td>2</td><td>$70</td></tr>
<tr><td>XML bible</td><td>$40.5</td><td>1</td><td>$40.5</td></tr>
<tr><td colspan="3" align="right"><b>Total amount -</b></td><td>$130.5</td></tr>
</table>
</body>
</html>

CSE.html
<html>
<head>

<title>CSE Page</title>
</head>

<p>Department of CSE Description</p>


</body>
</html>

Ece.html
<html>
<head>

<title>ECE Page</title>
</head>

<p>Department of ECE Description</p>


</body>
</html>

Eee.html

<html>
<head>

<title>EEE Page</title>
</head>

<p>Department of EEE Description</p>


</body>
</html>

Civil.html
<html>
<head>

<title>CIVIL Page</title>
</head>

<p>Department of CIVIL Description</p>


</body>
</html>
Output:
Execution Procedure
Step1: type all html programs in notepad or any text editor and save .html format.
Step2: open web browser and open index.html, i.e previous week.
Step3: traverse all pages from index.html.
EXP NO: 3
Design a web page using CSS which includes the following:
i.Use different font and text styles
ii. Set a background image for both the page and single element on the page.
iii. Define styles for links
iv. Working with layers
v. Adding a Customized cursor
Solutions:
1) 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.

Source code:
<HTML>
<HEAD>
<style type="text/css">
p.right
{
text-align:right;
font-size:30pt;
color:red;
text-transform:uppercase;
font-style:italic;
font-family:Bookman old style;
}
p.center
{
text-align:center;
font-size:25pt;
color:green;
text-decoration:overline;
text-transform:lowercase;
font-family:arial;
}
p.left
{
text-align:left;
font-size:20pt;
color:blue;
text-decoration:underline;
font-family:calibri;
}
h1.center
{
text-align:center;
color:maroon;
text-decoration:line-through;
text-transform:capitalize;
font-family:Bookman old style;
}
p.cls
{
font-size:15pt;
color:red;
word-spacing:50;
letter-spacing:-2;
}
</style>
</HEAD>
<BODY>
<p class="right">This is paragraph 1</p>
<p class="center">This is paragraph 2</p>
<p class="left">This is paragraph 3</p>
<h1 class="center">this is heading 1</h1>
<p class="cls">This is paragraph 4</p>
</BODY>
</HTML>
Output:

2) Set a background image for both the page and single elements on the page. You can define the
background image for the page like this:
BODY {background-image:url(myimage.gif),}
Source code:

<HTML>
<HEAD>
<style type='text/css'>
body
{
background-image:url(college.jpg);
background-repeat:no-repeat;
}
p
{
background-image:url(logo.jpg);
background-repeat:no-repeat;
font-size:30pt;
text-align:right;
background-position:top right;
}
</style>

</HEAD>
<BODY>
<p>This is paragraph 1</p>
</BODY>
</HTML>
Output:

3) Define styles for links as


A:link
A:visited
A:active
A:hover
Source code:
<HTML>
<HEAD>
<style type='text/css'>
*
{
text-align:center;
}
a:link
{
color:red;
text-decoration:none;
}
a:visited
{
text-decoration:underline;
color:pink;
}
a:hover
{
text-decoration:overline;
font-size:30pt;
color:yellow;
}
a:active
{
color:maroon;
font-size:30pt;
}
</style>
</HEAD>

<BODY>
<H1>Defining styles for Links</H1>
<p>Here you can change default properties of the link</p>
<a href="https://www.twitter.com">Twitter</a>
</BODY>
</HTML>
Output:

4) Work with layers:


For example:
LAYER 1 ON TOP:
<div style="position:relative, font-size:50px, z-index:2,">LAYER 1</div> <div
style="position:relative, top:-50, left:5, color:red, font-size:80px, z-
index:1">LAYER 2</div>

LAYER 2 ON TOP:
<div style="position:relative, font-size:50px, z-index:3,">LAYER 1</div> <div
style="position:relative, top:-50, left:5, color:red, font-size:80px, z-
index:4">LAYER 2</div>

Source code:

<HTML>
<HEAD>

</HEAD>

<BODY>
<strong>This is layer1</strong>
<div style="z-index:2;position:relative;font-size:30pt;color:orange">Top Layer 1</div>
<div style="z-index:1;position:relative;top:-30px;font-size:30pt;color:green">Bottom Layer1</div>

<strong>This is layer2</strong>
<div style="z-index:3;position:relative;font-size:30pt;color:orange">Top Layer 2</div>
<div style="z-index:4;position:relative;top:-30px;font-size:30pt;color:green">Bottom Layer
2</div>
</BODY>
</HTML>
Output:

5)Add a customized cursor:


Selector {cursor:value}
For example:
<html>
<head>
<style type="text/css">
.xlink {cursor:crosshair}
.hlink{cursor:help}
</style>
</head>

<body>
<b>
<a href="mypage.htm" class="xlink">CROSS LINK</a>
<br>
<a href="mypage.htm" class="hlink">HELP LINK</a>
</b>
</body>
</html>
Source code:

<HTML>
<HEAD>
<style type="text/css">
*
{
text-align:center;
}
</style>
</HEAD>
<BODY>
<a href="https://www.gmail.com" style="cursor:wait">Wait cursor</a><br>
<a href="https://www.gmail.com" style="cursor:crosshair">cross hair cursor</a><br>
<a href="https://www.gmail.com" style="cursor:text">text cursor</a><br>
<a href="https://www.gmail.com" style="cursor:e-resize">Resize cursor</a><br>
<a href="https://www.gmail.com" style="cursor:move">Move cursor</a><br>
<a href="https://www.gmail.com" style="cursor:help">Help cursor</a><br>
<a href="https://www.gmail.com" style="cursor:ne-resize">Ne resize cursor</a><br>
<a href="https://www.gmail.com" style="cursor:se-resize">se resize cursor</a><br>
</BODY>
</HTML>
Output:
EXP NO: 4
AIM:
i. Write a JavaScript to validate the fields of the login page.
ii. Write a JavaScript to validate the fields of the Registration page
Description
JavaScript is a lightweight interpreted programming language with rudimentary object-oriented
capabilities. Syntactically, the core JavaScript language resembles C, C++ and Java, with
programming constructs such as the if statement, the while loop, and the && operator. The
similarity ends with this syntactic resemblance, however. JavaScript is an untyped language,
which means that variables do not have to have a type specified.

The <SCRIPT> and </SCRIPT> tags are used to embed JavaScript code within an HTML file.
Source Code:
Registration.html:
<HTML>

<HEAD>

<script>

function validate()

if(register.name.value=="")

alert("Please enter your name");

register.name.focus();

return false;

if(register.name.value.length<8)

alert("User name should be minimum 8 characters");

register.name.focus();

return false;

if(register.password.value=="")
{

alert("Please enter your password");

register.password.focus();

return false;

if(register.password.value.length<10)

alert("Password should be minimum 10 characters");

register.name.focus();

return false;

var x=register.email.value;

var atpos=x.indexOf("@");

var at2pos=x.lastIndexOf("@");

var dotpos=x.lastIndexOf(".");

if(atpos<1||(atpos!=at2pos)||dotpos<1||atpos+2>dotpos||dotpos+2>=x.length)

alert("Please enter valid email id.....");

register.email.focus();

return false;

if(register.gender.value=="")

alert("Please select your gender");

register.gender.focus();
return false;

if(isNaN(register.date.value)||isNaN(register.month.value)||isNaN(register.year.value))

alert("Invalid Date of Birth.....");

register.date.focus();

return false;

if((register.telugu.checked==false)&&(register.hindhi.checked==false)&&(register.tamil.
checked==false)&&(register.english.checked==false))

alert("Please select languages........");

register.telugu.focus();

return false;

if(register.address.value=="")

alert("Please enter your Address......");

register.address.focus();

return false;

if(register.address.value.length<50)

alert("Address should me minimum 50 characters");


register.address.focus();

return false;

if(isNaN(register.mobile.value))

alert("Please enter digits.....");

register.mobile.focus();

return false;

if((register.mobile.value.length<10)||(register.mobile.value.length>10))

alert("Please enter valid mobile number...");

register.mobile.focus();

return false;

return true;

</script>

</HEAD>

<BODY bgcolor='#999900'>

<form name='register' action='register.jsp' onsubmit="return validate(this);">

<table align='center' cellspacing='20'>

<tr>

<td>Enter Name</td>

<td><input type='text' name="name"></td>


</tr>

<tr>

<td>Enter Password</td>

<td><input type='password' name="password"></td>

</tr>

<tr>

<td>Enter Email</td>

<td><input type='text' name="email"></td>

</tr>

<tr>

<td>Select Gender</td>

<td>

Male<input type='radio' name="gender" value='male'>

Female<input type='radio' name="gender" value='female'>

Other<input type='radio' name="gender" value='other'>

</td>

</tr>

<tr>

<td>Date of birth</td>

<td>

<select name='date'>

<option value='---date----'>date</option>

<script>

for(i=1;i<=31;i++)

document.write("<option value="+i+">"+i+"</option>")
</script>

</select>

<select name='month'>

<option value='---month---'>month</option>

<script>

for(i=1;i<=12;i++)

document.write("<option value="+i+">"+i+"</option>")

</script>

</select>

<select name="year">

<option value='---year---'>year</option>

<script>

for(i=1900;i<=2100;i++)

document.write("<option value="+i+">"+i+"</option>")

</script>

</select>

</td>

</tr>

<tr>

<td>Languages Known</td>

<td>

Telugu<input type='checkbox' name='telugu' value='telugu'>

Hindhi<input type='checkbox' name='hindhi' value='hidhi'>

Tamil<input type='checkbox' name='tamil' value='tamil'>

English<input type='checkbox' name='english' value='english'>


</td>

</tr>

<tr>

<td>Address</td>

<td><textarea name='address' rows='5' cols='25'></textarea></td>

</tr>

<tr>

<td>Mobile Number</td>

<td><input type="text" name="mobile"></td>

</tr>

<tr>

<td>

<input type='submit' value='Register'>

</td>

<td>

<input type='reset' value='Clear'>

</td>

</tr>

</table>

</form>

</BODY>

</HTML>

Output:
ii)Login.html:

<HTML>

<HEAD>

<script>

function validate()

var x=login.email.value;

var atpos=x.indexOf("@");

var at2pos=x.lastIndexOf("@");

var dotpos=x.lastIndexOf(".");

if(atpos<1||(atpos!=at2pos)||dotpos<1||atpos+2>dotpos||dotpos+2>=x.length)

alert("Please enter valid email id.....");


login.email.focus();

return false;

if(login.password.value=="")

alert("Please enter your password");

login.password.focus();

return false;

if(login.password.value.length<10)

alert("Password should be minimum 10 characters");

login.password.focus();

return false;

return true;

</script>

</HEAD>

<BODY bgcolor='#999900'>

<center>

<form name='login' action='login.jsp' onsubmit="return validate(this);">

<table>

<tr><td colspan='2' align='center'><h2>Login Page</h2></td></tr>

<tr><td>Enter Email</td><td><input type='text' name='email'></td></tr>


<tr><td>Enter Password</td><td><input type='password'
name='password'></td></tr>

<tr><td><input type='submit' value='Login'></td>

<td><input type='reset' value='Reset'></td>

</tr>

</table>

</form>

</center>

</BODY>

</HTML>

Output:
Week 5
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 XML schemas XSL and CSS for the above purpose.
Note: Give at least for 4 books. It should be valid syntactically.
Hint: You can use some xml editors like XML-spy

Description
Extensible Markup Language (XML) is a meta-markup language that provides a format for
describing structured data. This facilitates more precise declarations of content and more
meaningful search results across multiple platforms. In addition, XML is enabling a new
generation of Web-based data viewing and manipulation applications.
In the HTML you use tags to tell the browser to display data as bold or italic; in XML you use
tags only to describe data, such as city name, temperature, and barometric pressure. In XML, you
use style sheets such as Extensible Stylesheet Language (XSL) and Cascading Style Sheets
(CSS) to present the data in a browser. XML separates the data from the presentation and the
process, enabling you to display and process the data as you wish by applying different style
sheets and applications.

Source Code
a) Demonstrating DTD file

book.dtd
<!ELEMENT BOOKS (book)>
<!ELEMENT book (title,auther,ISBNnumber,publishername,editior,price)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT auther (#PCDATA)>
<!ELEMENT ISBNnumber (#PCDATA)>
<!ELEMENT publishername (#PCDATA)>
<!ELEMENT editor (#PCDATA)>
<!ELEMENT price (#PCDATA)>

Books1.xml
<?xml version="1.0" ?>
<!DOCTYPE books SYSTEM "books.dtd">
<books>
<book>
<title>java server page</title>
<author>hans bergsten</author>
<isbn>81-265</isbn>
<publisher>O'relilly</publisher>
<edition>second</edition>
<price>200</price>
</book>
<book>
<title>c</title>
<author>balaguruswamy</author>
<isbn>81-695</isbn>
<publisher>tata</publisher>
<edition>second</edition>
<price>400</price>
</book>
<book>
<title>web program</title>
<author>chirs bates</author>
<isbn>81-265</isbn>
<publisher>wiley</publisher>
<edition>second</edition>
<price>300</price>
</book>
</books>

b) Demonstrating XSD

books.css

books
{
color:orange;
}
book
{
color:Red;
}
title
{
color:blue;
font-weight:bold;
margin-left:10pt;
display:block;
}
author
{
color:red;
font-weight:bold;
margin-left:10pt;
}
isbn
{
color:green;
font-weight:bold;
margin-left:10pt;
}
edition
{
color:red;
font-weight:bold;
margin-left:10pt;
}
publisher
{
color:green;
font-weight:bold;
margin-left:10pt;
}

Books.xsd

<?xml version="1.0" encoding="iso-8859-1" ?>


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="books">
<xs:complexType>
<xs:sequence>
<xs:element name="book" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="book">
<xs:complexType>
<xs:sequence>
<xs:element ref="title" minOccurs="1" maxOccurs="1"/>
<xs:element ref="auther" minOccurs="1" maxOccurs="1"/>
<xs:element ref="isbn" minOccurs="1" maxOccurs="1"/>
<xs:element ref="publisher" minOccurs="1" maxOccurs="1"/>
<xs:element ref="edition" minOccurs="1" maxOccurs="1"/>
<xs:element ref="price" type="xs:string" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="title" type="xs.string"/>
<xs:element name="auther" type="xs.string"/>
<xs:element name="isbn" type="xs.string"/>
<xs:element name="publisher" type="xs.string"/>
<xs:element name="edition" type="xs.string"/>
<xs:element name="price" type="xs.string"/>
</xs:schema>

Books.xsl
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="books.css"?>
<books xmlns:xsi="http:www.w3.org/2001/xmlschema-instance"
xsi:noNamespaceSchemaLocation="books.xsd">
<book>
<title>web program</title>
<author>chirs bates</author>
<isbn>81-265</isbn>
<publisher>wiley</publisher>
<edition>second</edition>
<price>300</price>
</book>
<book>
<title>java server page</title>
<author>hans bergsten</author>
<isbn>81-265</isbn>
<publisher>O'relilly</publisher>
<edition>second</edition>
<price>200</price>
</book>
<book>
<title>c</title>
<author>balaguruswamy</author>
<isbn>81-695</isbn>
<publisher>tata</publisher>
<edition>second</edition>
<price>400</price>
</book>
</books>

c) Demonstrating XSL

books.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>
<head>
<title> books</title></head>
<body>
<table border="1">
<tr><th>title</th>
<th> auther</th>
<th> isbn</th>
<th>publisher</th>
<th>edition</th>
<th>price</th>
</tr>
<xsl:for-each select="/books/book">
<tr>
<td bgcolor="green"><xsl:value-of select="title"/></td>
<td bgcolor="red"><xsl:value-of select="author"/></td>
<td bgcolor="cyan"><xsl:value-of select="isbn"/></td>
<td bgcolor="yellow"><xsl:value-of select="publisher" /></td>
<td bgcolor="silver"><xsl:value-of select="edition" /></td>
<td bgcolor="blue"><xsl:value-of select="price" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Books3.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="books.xsl"?>
<books>
<book>
<title>java server page</title>
<author>hans bergsten</author>
<isbn>81-265</isbn>
<publisher>O'relilly</publisher>
<edition>second</edition>
<price>200</price>
</book>

<book>
<title>c</title>
<author>balaguruswamy</author>
<isbn>81-695</isbn>
<publisher>tata</publisher>
<edition>second</edition>
<price>400</price>
</book>
<book>
<title>web program</title>
<author>chirs bates</author>
<isbn>81-265</isbn>
<publisher>wiley</publisher>
<edition>second</edition>
<price>300</price>
</book>
</books>

Execution Procedure
Step1: Type all html programs in notepad or any text editor and save the files.
Step2: open appropriate xml files in web browser for getting output.

Output

Figure 1: Demonstrating DTD


Figure 2: Demonstrating XSD

Figure 3: Demonstrating XSL


WEEK 6: i. Write a PHP program to validate the fields of the login page.

ii. Write a PHP program to validate the fields of the Registration page

i) AIM: create a login page using HTML and process the login form in PHP using
super globals ($_GET or $_POST ) and validate the fields.
Login.html:
<html>
<head>
<title></title>
</head>
<body>
<form name='form' action='loginvalidation.php' method='get'>
<table>
<tr>
<td>Enter Name</td>
<td><input type='text' name='name'></td>
</tr>
<tr>
<td>Enter Password</td>
<td><input type='password' name='password'></td>
</tr>
<tr>
<td><input type='submit' value='login'></td>
</tr>
</table>
</form>
</body>
</html>
Loginvalidation.php:
<?php
//Reading Login Form using $_GET
$name=$_GET['name'];
$password=$_GET['password'];
$flag=true;
$msg="";
if($name=="")
{
$flag=false;
$msg="<h1>Please enter your name</h1>";
}
else if(strlen($name)<6)
{
$flag=false;
$msg="<h1>Name should be minimum 6 characters</h1>";
}
else if($password=="")
{
$flag=false;
$msg="<h1>Please enter your password</h1>";
}
else if(strlen($password)<6)
{
$flag=false;
$msg="<h1>Pasword should be minimum 6 characters</h1>";
}
else
{
echo "<h1>Login Success</h1>";
}
if(!$flag)
{
echo $msg;
}
?>
Output:
Open browser and type:
http://localhost/loginvalidation/login.html

Without name and password submitting the form:


Name with 4 characters submitting the form:

With valid name and empty password submitting the form:


With valid name and password 4 characters submitting the form:

With valid name and password:


ii) AIM: create a registration page using HTML and process the login form in PHP
using super globals ($_GET or $_POST ) and validate the fields.

register.html:
<html>
<head>
<title></title>
</head>
<body>
<form name='form' action='registervalidation.php' method='post'>
<table>
<tr>
<td>Enter Name</td>
<td><input type='text' name='name'></td>
</tr>
<tr>
<td>Enter Password</td>
<td><input type='password' name='password'></td>
</tr>
<tr>
<td>Enter Email</td>
<td><input type='text' name='email'></td>
</tr>
<tr>
<td>Enter Mobile</td>
<td><input type='text' name='mobile'></td>
</tr>
<tr>
<td>Enter Address</td>
<td>
<textarea name="address" cols="22" rows="5"></textarea>
</td>
</tr>
<tr>
<td><input type='submit' value='register'></td>
</tr>
</table>
</form>
</body>
</html>
Registervalidation.php:
<?php
//Reading Login Form using $_GET
$name=$_POST['name'];
$password=$_POST['password'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$address=$_POST['address'];
$flag=true;
$msg="";
if($name=="")
{
$flag=false;
$msg="<h1>Please enter your name</h1>";
}
else if($password=="")
{
$flag=false;
$msg="<h1>Please enter your password</h1>";
}
else if($email=="")
{
$flag=false;
$msg="<h1>Please enter your email</h1>";
}
else if($mobile=="")
{
$flag=false;
$msg="<h1>Please enter your mobile</h1>";
}
else if($address=="")
{
$flag=false;
$msg="<h1>Please enter your address</h1>";
}
else
{
echo "<h1>Registration Success</h1>";
}
if(!$flag)
{
echo $msg;
}
?>
Output:
Open browser and type:
http://localhost/registervalidation/register.html

Without name submitting form:


Without password submitting form:
WEEK 7: Write a JSP to connect to the database and extract data from the tables and display
them to the user.
AIM: Install a database (Mysql or Oracle).
Use JDBC connection steps to connect to the registration table and get the data
from table and display to the user.

DESCRIPTION:

JDBC Driver Types


There are four types of JDBC drivers in use:
Type 1: JDBC-ODBC Bridge
A Type 1 JDBC-ODBC Bridge provides application developers with a way to access JDBC
drivers via the JDBC API. Type 1 JDBC drivers translate the JDBC calls into ODBC calls and
then send the calls to the ODBC driver. Type 1 JDBC drivers are generally used when the
database client libraries need to be loaded on every client machine.
Type 2: Native API/Partly Java Driver
A Type 2 Native API/Partly Java Driver is a partial Java driver because it converts JDBC calls
into database specific calls. Type 2 Native API/Partly Java Driver communicates directly with
the database server.
Type 3: Pure Java Driver
A Type 3 Pure Java Driver works in a three tiered architecture. The JDBC calls are passed via
the network to the middle tier server. This server translates the calls to the database specific
native interface to further request the server. JDBC drivers available from Simba are Type 3
drivers.
Type 4: Native Protocol Java Driver
The type 4 driver is written completely in Java and is hence platform independent. It is installed
inside the Java Virtual Machine of the client. It provides better performance over the type 1 and
2 drivers as it does not have the overhead of conversion of calls into ODBC or database API
calls. Unlike the type 3 drivers, it does not need associated software to work.A Type 4 Native
Protocol Java Driver converts JDBC calls into the database specific calls so that the client
applications can communicate directly with the server.
Program:

Login.html:

<HTML>
<HEAD>
</HEAD>
<BODY bgcolor='#999900'>
<center>
<form name='login' action='retrieve.jsp' method="post">
<table>
<tr><td colspan='2' align='center'><h2>Login Page</h2></td></tr>
<tr><td>Enter Name</td><td><input type='text' name='name'></td></tr>
<tr><td>Enter Password</td><td><input type='password'
name='password'></td></tr>
<tr><td><input type='submit' value='Login'></td>
<td><input type='reset' value='Reset'></td>
</tr>
</table>
</form>
</center>
</BODY>
</HTML>
Retrieve.jsp:
<%@page import="java.sql.*"%>
<%
String name=request.getParameter("name");
String password=request.getParameter("password");
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/gec","root","root");
PreparedStatement ps=con.prepareStatement("select * from register where name=? and
password=?");
ps.setString(1,name);
ps.setString(2,password);
ResultSet rs=ps.executeQuery();%>
<%if(rs.next())
{%>
<center>
<table border='1'>
<tr>
<th>Name</th>
<th>Email</th>
<th>Gender</th>
<th>Date of Birth</th>
<th>Known Languages</th>
<th>Address</th>
<th>Mobile Number</th>
</tr>
<tr>
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
<td><%=rs.getString(5)%></td>
<td><%=rs.getString(6)%></td>
<td><%=rs.getString(7)%></td>
<td><%=rs.getString(8)%></td>
</tr>
<%}
else
{
out.println("Incorrect username or password");
}
%>
</table>
<center>
<%

}
catch(Exception e)
{
out.println(e);
}
%>
Save these files in the Root folder and Paste the Root folder in the following location:
D:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps
Run the server from following location:
D:\Program Files\Apache Software Foundation\Tomcat 7.0\bin
Now open the browser and type:
http://localhost:2025/Retrieve%20JSP/login.html

Output:
WEEK 8: Design a JSP to insert the details of the users who register through
the registration page and store the details in to the database.

AIM: Install a database (Mysql or Oracle).


Create a table which should contain at least the following fields: name,
password, email-id, phone number (these should hold the data from the registration
form).
Practice 'JDBC' connectivity.

DESCRIPTION:

JDBC Driver Types


There are four types of JDBC drivers in use:
Type 1: JDBC-ODBC Bridge
A Type 1 JDBC-ODBC Bridge provides application developers with a way to access JDBC
drivers via the JDBC API. Type 1 JDBC drivers translate the JDBC calls into ODBC calls and
then send the calls to the ODBC driver. Type 1 JDBC drivers are generally used when the
database client libraries need to be loaded on every client machine.
Type 2: Native API/Partly Java Driver
A Type 2 Native API/Partly Java Driver is a partial Java driver because it converts JDBC calls
into database specific calls. Type 2 Native API/Partly Java Driver communicates directly with
the database server.
Type 3: Pure Java Driver
A Type 3 Pure Java Driver works in a three tiered architecture. The JDBC calls are passed via
the network to the middle tier server. This server translates the calls to the database specific
native interface to further request the server. JDBC drivers available from Simba are Type 3
drivers.
Type 4: Native Protocol Java Driver
The type 4 driver is written completely in Java and is hence platform independent. It is installed
inside the Java Virtual Machine of the client. It provides better performance over the type 1 and
2 drivers as it does not have the overhead of conversion of calls into ODBC or database API
calls. Unlike the type 3 drivers, it does not need associated software to work.A Type 4 Native
Protocol Java Driver converts JDBC calls into the database specific calls so that the client
applications can communicate directly with the server.
Program:

Registration.html:
<HTML>
<HEAD>
<script>
function validate()
{
if(register.name.value=="")
{
alert("Please enter name...");
register.name.focus();
return false;
}
if(register.name.value.length<8)
{
alert("name should be minimum 8 characters....");
register.name.focus();
return false;
}
if(register.password.value=="")
{
alert("Please enter password...");
register.password.focus();
return false;
}
if(register.password.value.length<8)
{
alert("password should be minimum 8 characters....");
register.password.focus();
return false;
}
var x=register.email.value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
var at2pos=x.lastIndexOf("@");

if(atpos<1||dotpos<1||(atpos!=at2pos)||atpos+2>dotpos||dotpos+2>=x.length)
{
alert("Please enter valid email address");
register.email.focus();
return false;
}
if(register.gender.value=="")
{
alert("Please select gender");
register.gender.focus();
return false;
}

if(isNaN(register.date.value)||isNaN(register.month.value)||isNaN(register.ye
ar.value))
{
alert("Invalid date of birth");
register.date.focus();
return false;
}
if((register.telugu.checked==false)&&(register.hindhi.checked==false)&&(r
egister.tamil.checked==false)&&(register.english.checked==false))
{
alert("Please select languages");
register.telugu.focus();
return false;
}
if(register.addr.value=="")
{
alert("Please enter address");
register.addr.focus();
return false;
}
if(isNaN(register.mobile.value))
{
alert("Please enter digits only");
register.mobile.focus();
return false;
}

if((register.mobile.value=="")||(register.mobile.value.length>10)||(register.m
obile.value.length<10))
{
alert("Please enter valid mobile number");
register.mobile.focus();
return false;
}
return true;
}
</script>
</HEAD>
<BODY bgcolor='#999900'>
<form name='register' action='registration.jsp' onsubmit="return
validate(this);">
<table align='center' cellspacing='20'>
<tr>
<td>Enter Name</td>
<td><input type='text' name="name"></td>
</tr>
<tr>
<td>Enter Password</td>
<td><input type='password' name="password"></td>
</tr>
<tr>
<td>Enter Email</td>
<td><input type='text' name="email"></td>
</tr>
<tr>
<td>Select Gender</td>
<td>
Male<input type='radio' name="gender" value='male'>
Female<input type='radio' name="gender" value='female'>
Other<input type='radio' name="gender" value='other'>
</td>
</tr>
<tr>
<td>Date of birth</td>
<td>
<select name='date'>
<option value='---date----'>date</option>
<script>
for(i=1;i<=31;i++)
document.write("<option value="+i+">"+i+"</option>");
</script>
</select>
<select name='month'>
<option value='---month---'>month</option>
<script>
for(i=1;i<=12;i++)
document.write("<option value="+i+">"+i+"</option>");
</script>
</select>
<select name="year">
<option value='---year---'>year</option>
<script>
for(i=1900;i<=2100;i++)
document.write("<option value="+i+">"+i+"</option>");
</script>
</select>
</td>
</tr>
<tr>
<td>Languages Known</td>
<td>
Telugu<input type='checkbox' name='telugu' value='telugu'>
Hindhi<input type='checkbox' name='hindhi' value='hindhi'>
Tamil<input type='checkbox' name='tamil' value='tamil'>
English<input type='checkbox' name='english' value='english'>
</td>
</tr>
<tr>
<td>Address</td>
<td><textarea name="addr" rows='5' cols='25'></textarea></td>
</tr>
<tr>
<td>Mobile Number</td>
<td><input type='text' name="mobile"></td>
</tr>
<tr>
<td>
<input type='submit' value='Register'>
</td>
<td>
<input type='reset' value='Clear'>
</td>
</tr>
</table>
</form>
</BODY>
</HTML>

Registration.jsp:
<%@page import="java.sql.*"%>
<%
String name=request.getParameter("name");
String password=request.getParameter("password");
String email=request.getParameter("email");
String gender=request.getParameter("gender");
String date=request.getParameter("date");
String month=request.getParameter("month");
String year=request.getParameter("year");
String telugu=request.getParameter("telugu");
String hindhi=request.getParameter("hindhi");
String english=request.getParameter("english");
String tamil=request.getParameter("tamil");
String addr=request.getParameter("addr");
String mobile=request.getParameter("mobile");
String languages="";
if(telugu!=null)
{
languages=languages+telugu+",";
}
if(hindhi!=null)
{
languages=languages+hindhi+",";
}
if(english!=null)
{
languages=languages+english+",";
}
if(tamil!=null)
{
languages=languages+tamil+",";
}
//Connection to database
Class.forName("com.mysql.jdbc.Driver");
Connection
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/gec","root","roo
t");
PreparedStatement ps=conn.prepareStatement("insert into register
values(?,?,?,?,?,?,?,?)");
ps.setString(1,name);
ps.setString(2,password);
ps.setString(3,email);
ps.setString(4,gender);
ps.setString(5,date+"-"+month+"-"+year);
ps.setString(6,languages);
ps.setString(7,addr);
ps.setString(8,mobile);
int i=ps.executeUpdate();
if(i!=0)
{
out.println("<h1>Registered Successfully.....</h1>");
}
conn.close();
%>

Save these two files in the Root Directory….


Copy the root folder and paste in the following location
D:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps
Run the server from following location
D:\Program Files\Apache Software Foundation\Tomcat 7.0\bin\tomcat7.exe
Open the browser and type following URL
http://localhost:2025/Registration/registration.html
screen shots:
WEEK 9: Write a PHP program to connect to MySQL database which retrieves the data
from the tables and display them to the user.

AIM: Use PHP to MySQL database connection steps and retrieve the data from the register table
and display to the user.

Login.html:

<HTML>

<HEAD>

</HEAD>

<BODY bgcolor='#999900'>

<center>

<form name='login' action='retrieve.php' method="post">

<table>

<tr><td colspan='2' align='center'><h2>Login Page</h2></td></tr>

<tr><td>Enter Name</td><td><input type='text' name='name'></td></tr>

<tr><td>Enter Password</td><td><input type='password'


name='password'></td></tr>

<tr><td><input type='submit' value='Login'></td>

<td><input type='reset' value='Reset'></td>

</tr>

</table>

</form>

</center>

</BODY>

</HTML>

Login.php:

<?php
//Reading Values from form

$name =$_POST['name'];

$password =$_POST['password'];

//Connecting to Mysql Using PHP

$dbhost = "localhost:3306";

$dbuser = "root";

$dbpass = "root";

$conn = mysqli_connect($dbhost, $dbuser, $dbpass);

if (!$conn) {

die("Connection failed: " . mysqli_connect_error());

echo "Connected successfully";

$sql = "SELECT * FROM gec.register where name='$name' and


password='$password'";

$result = $conn->query($sql);

if ($result->num_rows > 0) {

echo "<center>

<table border='1'>

<tr>

<th>Name</th>

<th>Email</th>

<th>Gender</th>

<th>Date of Birth</th>

<th>Known Languages</th>

<th>Address</th>
<th>Mobile Number</th>

</tr>";

// output data of each row

while($row = $result->fetch_assoc()) {

echo "<tr>

<td>".$row["name"]."</td>

<td>".$row["email"]."</td>

<td>".$row["gender"]."</td>

<td>".$row["dob"]."</td>

<td>".$row["languages"]."</td>

<td>".$row["addr"]."</td>

<td>".$row["mobile"]."</td>

</tr>";

echo "</table>";

else

echo "Sorry Incorrect User Name or Password....";

$conn->close();

?>

Output:

Open the browser and type following:


http://localhost/Retrieve%20PHP/login.html
WEEK 10: Write a PHP program to insert the details entered by the user in the
registration form into MySQL database.
AIM: Create a table which should contain at least the following fields: name,
password, email-id, phone number (these should hold the data from the registration
form).

Registration.html:
<HTML>
<HEAD>
</HEAD>
<BODY bgcolor='#999900'>
<form name='register' method="post" action='register.php' onsubmit="return
validate(this);">
<table align='center' cellspacing='20'>
<tr>
<td>Enter Name</td>
<td><input type='text' name="name"></td>
</tr>
<tr>
<td>Enter Password</td>
<td><input type='password' name="password"></td>
</tr>
<tr>
<td>Enter Email</td>
<td><input type='text' name="email"></td>
</tr>
<tr>
<td>Select Gender</td>
<td>
Male<input type='radio' name="gender" value='male'>
Female<input type='radio' name="gender" value='female'>
Other<input type='radio' name="gender" value='other'>
</td>
</tr>
<tr>
<td>Date of birth</td>
<td>
<select name='date'>
<option value='---date----'>date</option>
<script>
for(i=1;i<=31;i++)
document.write("<option value="+i+">"+i+"</option>");
</script>
</select>
<select name='month'>
<option value='---month---'>month</option>
<script>
for(i=1;i<=12;i++)
document.write("<option value="+i+">"+i+"</option>");
</script>
</select>
<select name="year">
<option value='---year---'>year</option>
<script>
for(i=1900;i<=2100;i++)
document.write("<option value="+i+">"+i+"</option>");
</script>
</select>
</td>
</tr>
<tr>
<td>Languages Known</td>
<td>
Telugu<input type='checkbox' name='telugu' value='telugu'>
Hindhi<input type='checkbox' name='hindhi' value='hindhi'>
Tamil<input type='checkbox' name='tamil' value='tamil'>
English<input type='checkbox' name='english' value='english'>
</td>
</tr>
<tr>
<td>Address</td>
<td><textarea name="addr" rows='5' cols='25'></textarea></td>
</tr>
<tr>
<td>Mobile Number</td>
<td><input type='text' name="mobile"></td>
</tr>
<tr>
<td>
<input type='submit' value='Register'>
</td>
<td>
<input type='reset' value='Clear'>
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
Register.php:
<?php
//Reading Values from form
$name =$_POST['name'];
$password =$_POST['password'];
$email =$_POST['email'];
$gender =$_POST['gender'];
$dob=$_POST['date']."-".$_POST['month']."-".$_POST['year'];
$languages="";
if($_POST['telugu']!=null)
{
$languages=$languages.$_POST['telugu'].",";
}
if($_POST['hindhi']!=null)
{
$languages=$languages.$_POST['hindhi'].",";
}
if($_POST['tamil']!=null)
{
$languages=$languages.$_POST['tamil'].",";
}
if($_POST['english']!=null)
{
$languages=$languages.$_POST['english'].",";
}
$addr =$_POST['addr'];
$mobile =$_POST['mobile'];
//Connecting to Mysql Using PHP
$dbhost = "localhost:3306";
$dbuser = "root";
$dbpass = "root";
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
$sql = "INSERT INTO gec.register VALUES ".
"('$name','$password','$email','$gender','$dob','$languages','$addr','$mobile')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
}
else
{
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>
Output:
Open the browser and type following URL
http://localhost/Register%20PHP/registration.html

You might also like