WEB TECHNOLOGYS
WEB TECHNOLOGYS
WEB TECHNOLOGYS
LABORATORY MANUAL
B.TECH
(III YEAR – II SEM)
(2021-2022)
Vision
To acknowledge quality education and instill high patterns of
discipline making the students technologically superior and ethically
strong which involves the improvement in the quality of life in
human race.
Mission
To achieve and impart holistic technical education using the best of
infrastructure, outstanding technical and teaching expertise to
establish the students into competent and confident engineers.
Evolving the center of excellence through creative and innovative
teaching learning practices for promoting academic achievement to
produce internationally accepted competitive and world class
professionals.
PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)
2. To facilitate the graduates with the technical skills that prepare them for
immediate employment and pursue certification providing a deeper
understanding of the technology in advanced areas of computer science and
related fields, thus encouraging to pursue higher education and research based
on their interest.
3. To facilitate the graduates with the soft skills that include fulfilling the mission,
setting goals, showing self-confidence by communicating effectively, having a
positive attitude, get involved in team-work, being a leader, managing their
career and their life.
1. Students are advised to come to the laboratory at least 5 minutes before (to the
starting time), those who come after 5 minutes will not be allowed into the lab.
2. Plan your task properly much before to the commencement, come prepared to the
lab with the synopsis / program / experiment details.
3. Student should enter into the laboratory with:
a. Laboratory observation notes with all the details (Problem statement, Aim,
Algorithm, Procedure, Program, Expected Output, etc.,) filled in for the lab session.
b. Laboratory Record updated up to the last session experiments and other utensils (if
any) needed in the lab.
c. Proper Dress code and Identity card.
4. Sign in the laboratory login register, write the TIME-IN, and occupy the computer
system allotted to you by the faculty.
5. Execute your task in the laboratory, and record the results / output in the lab
observation note book, and get certified by the concerned faculty.
6. All the students should be polite and cooperative with the laboratory staff, must
maintain the discipline and decency in the laboratory.
7. Computer labs are established with sophisticated and high end branded systems,
which should be utilized properly.
8. Students / Faculty must keep their mobile phones in SWITCHED OFF mode during
the lab sessions.Misuse of the equipment, misbehaviors with the staff and systems
etc., will attract severe punishment.
9. Students must take the permission of the faculty in case of any urgency to go out ; if
anybody found loitering outside the lab / class without permission during working
hours will be treated seriously and punished appropriately.
10. Students should LOG OFF/ SHUT DOWN the computer system before he/she leaves
the lab after completing the task (experiment) in all aspects. He/she must ensure
the system / seat is kept properly.
Outcomes:
Upon successful completion of this course, the students will be able to:
Develop and demonstrate the usage of inline, internal and externalstyle sheet
2 using CSS 10-13
Write JavaScript to validate the following fields of the Registrationpage.
3 14-19
1. First Name (Name should contains alphabets and the lengthshould not
be less than 6 characters).
2. Password (Password should not be less than 6 characters length).
3. E-mail id (should not contain any invalid and must follow the
standard pattern [email protected])
4. Mobile Number (Phone number should contain 10 digits only).
Last Name and Address (should not be Empty).
Develop and demonstrate JavaScript with POP-UP boxes andfunctions for the
4 following problems: 20-21
a) Input: Click on Display Date button using onclick( ) function
Output: Display date in the textbox
Write an XML file which will display the book information which includes the 25-29
7 following:
1) Title of the book
2) Author name
3) ISBN number
4) Publisher name
5) Edition
6) Price
Write a 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.
8 Develop and demonstrate PHP Script for the following problems: 30-32
a) Write a PHP Program to display current Date, Time and Day.
b) Write a PHP Script to check whether the given number is palindrome or not.
c) A web application that takes name and age from an HTML page. If the age is
less than 18, it should send a page with “Hello <name>, you are not
authorized to visit the site” message, where <name> should be replaced
withthe entered name. Otherwise it should send “Welcome <name> to
this site” message.
9 Implement the following web applications using Servlets 33-39
i) A web application that takes a name as input and on submit it shows a
hello <name> page where name is taken from the request. It shows the
start time at the right top corner of the page and provides a logout
button. On clicking this button, it should show a logout page with Thank
You <name > message with the duration of usage (hint: Use session to
store name and time).
ii) Write a PHP Program to display current Date, Time and Day.
iii) A web application that takes name and age from an HTML page. If the
age is less than 18, it should send a page with “Hello <name>, you are
not authorized to visit the site” message, where <name> should be
replaced withthe entered name. Otherwise it should send “Welcome
<name> to this site” message.
iv) A web application that lists all cookies stored in the browser on
clicking“List Cookies” button. Add cookies if necessary.
10 40-44
Implement the web applications with Database using
(a) PHP, (b) Servlets
12 50-57
Write a program to design a simple calculator using (a) JavaScript (b)PHP (c)
Servlet and (d) JSP.
‘
WEB TECHNOLOGIES LAB MRCET
WEEK 1:
Design the following static web pages required for an online book store web site.
1) HOME PAGE: The static home page must contain three frames.
2) LOGIN PAGE
3) CATOLOGUE PAGE: The catalogue page should contain the details of all the
booksavailable in the web site in a table.
4) REGISTRATION PAGE
Aim: Design the following static web pages required for online book store.
1. Home page:- the static home page must contains three pages
2. Top frame:- logo and college name and links to homepage, login page, registration
pageand catalogue page
3. Left frame:- at least four links for navigation which will display the catalogue of
Respective links
4. Right frame:- the pages to links in the left frame must be loaded here initially it
Containsthe description of the website.
DESCRIPTION: In this program the entire web paged are created by using basic
HTML tags. Home page is divided into 3 frames by using <frameset> and <frame>
tags. A frame isused to display a web page within a web page.
<frameset>:
The <frameset> tag defines a frameset.
The <frameset> element holds one or more <frame> elements.
Each <frame> element can hold a separate document.
The <frameset> element specifies HOW MANY columns or rows there will be
in the frameset, and HOW MUCH percentage/pixels of space will occupy each of
them.
<frame>:
The <frame> tag defines one particular window (frame) within a <frameset>.
Each <frame> in a <frameset> can have different attributes, such as border,
scrolling, the ability to resize, etc.
PROGRAM:
home.html:
<frameset rows="40%,*">
<frame src="top.html" noresize scrolling="NO" name="topframe">
<frameset cols="15%,*">
<frame src="left.html" noresize scrolling="NO" name="leftframe">
<frame src="right.html" noresize name="rightframe" scrolling="auto">
</frameset>
</frameset>
top.html:
<html>
<head>
<title>Top Frame</title>
</head>
<body bgcolor="YellowGreen ">
DEPARTMENT OF CSE 1
WEB TECHNOLOGIES LAB MRCET
left.html:
<html>
<body align="center" bgcolor="bisque"> <br>
<a href="cse.html" target="rightframe"><font size="6">CSE</font></a><br><br>
<a href="ece.html" target="rightframe"><font size="6">ECE</font></a><br><br>
<a href="eee.html" target="rightframe"><font size="6">EEE</font></a><br><br>
<a href="mech.html" target="rightframe"><font size="6">MECH</font></a><br>
</body>
</html>
right.html:
<html>
<body bgcolor="orange">
<center>
<img src="images/Books.jpg" height="170"><br>
<font face="Brush Script MT" size="5" color="blue">
<h1><b>Welcome to the Online Book Store!!!</b></font><br />
<font face="Brush Script MT" size="5" color="red">
<h2><b> "A Huge Collection Of Engineering E-Books"</b></h2></font>
</center>
</body>
</html>
DEPARTMENT OF CSE 2
WEB TECHNOLOGIES LAB MRCET
cse.html:
<html>
<head><title>CSE</title></head>
<body bgcolor="cyan">
<center><font color="blue"><h1>Computer Science and Engineering</h1></font></center>
<br>
<table align="center">
<tr>
<td>Text Books</td>
<td>
<select >
<option value="select the book" selected>Select the book
<option value="C&Ds">C&Ds
<option value="Ads">Ads
<option value="Java">Java
<option value="Oracle">Oracle
<option value="Ms SQL Server">Ms SQL Server
<option value="MySql">MySql
</select>
</td></tr>
<tr>
<td>Quantity</td>
<td><input type="text" id="q"></td>
</tr>
<tr>
<td></td>
<td>
<form method=post action="order.html">
<input type="submit" value=ok />
</form>
</td>
</tr>
</table>
<center>
<pre> Cost of one book is"500" + shipping "100" </pre>
</center>
</body>
</html>
ece.html:
<html>
<body bgcolor="Plum">
<h1><font color="blue">Electronics and Communication Engineering</font></h1>
<h2>
<ul>
<li>Digital Circuits</li> <li>Signals and Systems</li> <li>Digital Communication</li>
</ul>
</h2>
</body>
</html>
DEPARTMENT OF CSE 3
WEB TECHNOLOGIES LAB MRCET
eee.html:
<html>
<body bgcolor="Plum">
<h1><font color="blue">Electrical and Electronics Engineering</font></h1>
<h2>
<ul type="square">
<li>Concepts in Electric Circuits</li>
<li>Introduction to Electronic Engineering</li>
<li>Electrical Power</li>
</ul>
</h2>
</body>
</html>
mech.html:
<html>
<body bgcolor="Plum">
<h1><font color="blue">Electronics and Communication Engineering</font></h1>
<h2>
<ol type="I">
<li>Theory of Machines</li>
<li>Automation and Robotics</li>
<li>Engineering Fluid Mechanics</li>
</ol>
</h2>
</body>
</html>
catalogue.html:
<html>
<head>
<title> Catalogue </title>
</head>
<body bgcolor="pink">
<form action="order.html">
<table border="1" width="100%">
<tr>
<td>
<img src="images/wt.jpg" width=100 height=100/>
</td>
<td> Book: Web Technologies <br> Author: Uttam K. Roy <br>
Publication:OxfordUniversity Press</td> <td>531
</td>
<td> <input type="submit" value="Add to cart"/></td> </tr>
<tr>
<td> <img src="images/php.jpg" width=100 height=100/></td>
<td> Book: PHP & MySQL Web Development <br> Author:Luke Welling &
Laura Thompson <br> Publication:PEARSON</td> <td> 898
</td>
<td> <input type="submit" value="Add to cart"/></td> </tr>
DEPARTMENT OF CSE 4
WEB TECHNOLOGIES LAB MRCET
</table> </form>
</body> </html>
login.html:
<html>
<body bg color="pink">
<basefont face="Cambria" size="4"> <br>
<center>
<img src="images/login.jpg" width="385" height="135" /><br />
<font face="Brush Script MT" size="7" color="purple">
<b>Enter Login Details:</b>
</font>
</center>
<form name="f1" method="post" action="right.html">
<table align="center" width="100" height="150" cellspacing=”15”>
<tr><td><b>Login ID:</b></td>
<td><input type="text" name="t1"></td>
</tr>
<tr>
<td><b>Password:</b></td>
<td><input type="password" name="t2"></td>
</tr>
<tr align="center">
<td><input type="submit" name="b1" value="Submit"></td>
<td><input type="reset" name="b2" value="Reset"></td>
</tr>
</table> </form> </basefont> </body> </html>
registration.html:
<html>
<head><title>Registration Form</title></head>
<body bgcolor="#E4F0F8">
<center><font color="blue" size="6" face="arial">Registration Form</font></center><br />
<form action="right.html">
First Name(Minimum 6 characters)<font color="red">* </font>
<input type='text' id='firstname' /><br /><br />
Last Name<font color="red"><font color="red">* </font> </font>
<input type='text' id='lastname' /><br /><br />
EmailAddress<font color="red">* </font>
<input type='text' id='email' /><br />
<font color="red">(one e-mail id only):</font>
<font color="redblue">e.g. [email protected]</font><br /><br/>
Password(minimum 6 characters)<font color="red">* </font>
<input type='password' id='pass'><br /><br/>
Address<font color="red">* </font>
<textarea rows="2" cols="20" id='addr' /></textarea> <br />
<br/>Mobile No<font color="red">* </font>
DEPARTMENT OF CSE 5
WEB TECHNOLOGIES LAB MRCET
<input type='text' id='mobileno' /><br />
Gender: <input type='radio'
name="gender">male
<input type='radio' name="gender">female<br/><br />
<input type='Submit' value='submit' />
<input type='Reset' value='reset' />
</form> </body> </html>
order.html:
<html>
<head><title>order conformation</title></head>
<body bgcolor="cyan">
<center>
<pre><strong>
<b>Your order Is Conformed
</strong></pre>
<h2><b>THANK YOU...Visit Again</h2>
</center>
</body>
</html>
OUTPUT:
DEPARTMENT OF CSE 6
WEB TECHNOLOGIES LAB MRCET
DEPARTMENT OF CSE 7
WEB TECHNOLOGIES LAB MRCET
DEPARTMENT OF CSE 8
WEB TECHNOLOGIES LAB MRCET
DEPARTMENT OF CSE 9
WEB TECHNOLOGIES LAB MRCET
WEEK - 2: Develop and demonstrate the usage of inline, internal and external style
sheet using CSS.
Aim: Design a web page using CSS which includes the following:
1) Use different font styles
2) Control the repetition of image with background-repeat and no-repeat property
3) Define style for links as a: link, a: active, a: hover, a: visited
4) Add customized cursors for links.
PROGRAM:
style.css
p.left
{
text-
align:left;
color:blue
;
font-
family:Cambria;
font-size:large;
text-indent:20px;
}
p.center
{
text-align:center;
text-
decoration:underline;
text-
transform:uppercase;
letter-spacing:-3px;
word-
spacing:20px;
font-size:larger;
}
p.right
{
text-
align:right;
color:red;
font-
family:Tahoma;
font-size:15pt;
text-
decoration:overline;
font-style:italic;
DEPARTMENT OF CSE 10
WEB TECHNOLOGIES LAB MRCET
}
b#headline
{
color:orange;
font-
size:22px;
font-
family:arial;
text-decoration:underline;
}
sample.html
<html>
<head>
<style
type="text/css">
body
{
background-
image:url('images/cse.png');
background-repeat:no-repeat;
background-position:center center;
background-attachment:fixed;
background-color:pink;
}
a:link { text-decoration:none;color:orange; }
a:visited { text-decoration:none;color:red; }
a:hover { text-decoration:underline;color:blue;
} a:active { text-
decoration:underline;color:purple; } h3 {
color:green; }
.c1{cursor:crosshair}
.c2{cursor:pointer}
.c3{cursor:move}
.c4{cursor:text}
.c5{cursor:wait}
.c6{cursor:help}
</style>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body bgcolor="cyan">
<h1 style="color:blue;text-align:center;"> CSS (Inline, Internal and External) </h1>
<p>This Paragraph is a Not Styled</p>
<p class="left">This Paragraph is Styled by class "Left"</p>
DEPARTMENT OF CSE 11
WEB TECHNOLOGIES LAB MRCET
OUTPUT 1:
DEPARTMENT OF CSE 12
WEB TECHNOLOGIES LAB MRCET
DEPARTMENT OF CSE 13
WEB TECHNOLOGIES LAB MRCET
WEEK 3: Write JavaScript to validate the following fields of the Registration page.
1. First Name (Name should contains alphabets and the length should not be less
than 6characters).
2. Password (Password should not be less than 6 characters length).
3. E-mail id (should not contain any invalid and must follow the standard pattern
[email protected])
4. Mobile Number (Phone number should contain 10 digits only).
5. Last Name and Address (should not be Empty).
DEPARTMENT OF CSE 14
WEB TECHNOLOGIES LAB MRCET
}
}
}
} } }
return false;
}
function notEmpty(elem, helperMsg)
{
if(elem.value.length == 0)
{
alert(helperMsg); elem.focus(); // set the focus to this input return false; }
return true;
}
function isNumeric(elem, helperMsg)
{
var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression))
{
return true;
}
Else
{
alert(helperMsg); elem.focus(); return false;
}
}
function isAlphabet(elem, helperMsg)
{
var alphaExp = /^[a-zA-Z]+$/; if(elem.value.match(alphaExp))
{
return true;
}
Else
{
alert(helperMsg); elem.focus();
return false;
}
}
function isAlphanumeric(elem, helperMsg)
{
var alphaExp = /^[0-9a-zA-Z]+$/;
if(elem.value.match(alphaExp))
{
return true;
}
Else
{
alert(helperMsg); elem.focus();
return false;
}
}
function lengthRestriction(elem, min)
DEPARTMENT OF CSE 15
WEB TECHNOLOGIES LAB MRCET
{
var uInput = elem.value;
if(uInput.length >= min)
{
return true;
}else
{
alert("Please enter minimum " +min+ " characters");
elem.focus();
return false;
}
}
function emailValidator(elem, helperMsg)
{
var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if(elem.value.match(emailExp))
{
return true;
}
else{ alert(helperMsg); elem.focus();
return false;
}
}
function lengthRestriction1(elem, min, max)
{
var uInput = elem.value;
if(uInput.length >= min && uInput.length <= max)
{
return true;
}
else { alert("Please enter 10 numbers only");
elem.focus();
return false; }
}
</script>
<center>
<font color="blue" size="6" face="arial">Registration Form</font></center><br />
<form onsubmit='return formValidator()' action="right.html">
First Name(Minimum 6 characters)<font color="red">* </font>
<input type='text' id='firstname' /><br /><br />
Last Name<font color="red"><font color="red">* </font> </font>
<input type='text' id='lastname' /><br /><br />
Email Address<font color="red">* </font>
<input type='text' id='email' /><br /> <font color="red">(one e-mail id only):</font>
<font color="redblue">e.g. [email protected]</font><br /><br/>
Password(minimum 6 characters)<font color="red">* </font>
<input type='password' id='pass'><br /><br/> Address<font color="red">* </font>
<textarea rows="2" cols="20" id='addr' /></textarea> <br /> <br/>
Mobile No<font color="red">* </font> <input type='text'
id='mobileno' /><br /> Gender: <input type='radio' name="gender">male <input
DEPARTMENT OF CSE 16
WEB TECHNOLOGIES LAB MRCET
OUTPUT:
DEPARTMENT OF CSE 17
WEB TECHNOLOGIES LAB MRCET
DEPARTMENT OF CSE 18
WEB TECHNOLOGIES LAB MRCET
DEPARTMENT OF CSE 19
WEB TECHNOLOGIES LAB MRCET
WEEK - 4: Develop and demonstrate JavaScript with POP-UP boxes and functions
forthe following problems:
a) Input: Click on Display Date button using onclick( )
functionOutput: Display date in the textbox
b) Input: A number n obtained using prompt
Output: Factorial of n number using alert
c) Input: A number n obtained using Prompt
Output: A multiplication table of numbers from 1 to 10 of n using alert
d) Input: A number n obtained using prompt and add another number using confirm
Output: Sum of the entire n numbers using
alertPROGRAM:
a) date.html
<html>
<body>
<script>
function display(){
var x="You have
clicked";var d=new
Date();
var date=d.getDate();
var
month=d.getMonth();
month++;
var year=d.getFullYear();
document.getElementById("dis").value=date+"/"+month+"/"+year;
}
</script>
<form>
<input type="text" id="dis" /><br />
<input type="button" value="Display Date" onclick="display()" />
</form>
<body>
</html>
OUTPUT:
b) factorial.html
<html>
<head>
DEPARTMENT OF CSE 20
WEB TECHNOLOGIES LAB MRCET
<title>factorial</title>
<script language='javascript'> function factorialcalc()
{
number = parseint(prompt("enter a number, i'll calculate its factorial",
"wholenumbers bigger than zero, please"))
factorial = 1
for (i=1; i <= number; i++)
{
factorial = factorial * i
}
alert("the factorial of " + number + " is " + factorial)
}
</script>
</head>
<body><form name=frm>
<input type=button value='factorial' onclick="factorialcalc();">
</form>
</body>
</html>
OUTPUT:
DEPARTMENT OF CSE 21
WEB TECHNOLOGIES LAB MRCET
WEEK - 5:
a) Input: A number n obtained using prompt
Output: A multiplication table of numbers from 1 to 10 of n using alert
b) Input: A number n obtained using prompt and add another numberusing confirm
Output: Sum of the entire n numbers using alert
PROGRAM:
A) multable.html
<html>
<head><title> Multiplication Table </title></head>
<body>
<script type="text/javascript">
<!--
var n=prompt("Enter positive value for n:
"," ");if(!isNaN(n)) {
var
table="";
var
number="";
for(i=1;i<=10;i++) {
number = n * i;
table += n + " * " + i + " = " + number + "\n";
}
alert(table);
}
else {
alert("Enter positive value"); n=prompt("Enter
positive value for n: "," ");
}
document.write(n+" table values displayed using alert ..<br />");
// -->
</script>
</body>
</html>
OUTPUT:
DEPARTMENT OF CSE 22
WEB TECHNOLOGIES LAB MRCET
B) sum of n numbers.html
<html>
<head><title>sum of n numbers using popup boxes</title>
<script
language='javascript'>
function addsum()
{
alert("you're going to give me a list of numbers. i'm going to add them together for
you");var keepgoing = true
var sumofnums =
0 while
(keepgoing) {
sumofnums = sumofnums + parseint(prompt("what's the next number to
add?","")) keepgoing = confirm("add another number?")
}
alert("the sum of all your numbers is " + sumofnums)
}
</script>
</head>
<body>
<form name=frm>
<input type=button value='sum of n numbers' onclick="addsum();">
</form>
</body>
</html>
OUTPUT:
DEPARTMENT OF CSE 23
WEB TECHNOLOGIES LAB MRCET
WEEK - 6:
Write an HTML page that contains a selection box with a list of 5 countries. When
the user selects a country, its capital should be printed next in the list. Add CSS to
customize the properties of the font of the capital (color,bold and font size).
<html>
<head>
<title>WT Lab manual program no. 3</title>
</head>
<style>
h1{
color: red;
text-align: center;
}
.textbox1
{
color: blue;
font-size:
30px;
font-weight: bold; }
</style>
<body>
<center>
<h1> Select the country name to find its capital</h1>
<form name="myform">
Select Country <select name="country" id="sbox1" onClick="myFunction()" required>
<option value=""></option>
<option value="NEW DELHI">INDIA</option>
<option value="CANBERRA">AUSTRALIA</option>
<option value="WASHINGTON D.C">AMERICA</option>
<option value="LONDON">UNITEDKINGDOM</option>
<option value="BERLIN">GERMANY</option>
</select><br><br>
Capital <input type="text" class="textbox1" id="sbox2">
</form>
</center>
<script>
function myFunction()
{ var a=document.getElementById("sbox1").value;
document.getElementById("sbox2").value=a; }
</script> </body> </html>
OUTPUT:
DEPARTMENT OF CSE 24
WEB TECHNOLOGIES LAB MRCET
WEEK - 7:
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 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
PROGRAM:
XML document (bookstore.xml)
<bookstore>
<book>
<title>web programming</title>
<author>chrisbates</author>
<ISBN>123-456-789</ISBN>
<publisher>wiley</publisher>
<edition>3</edition>
<price>350</price>
</book>
<book>
<title>internet worldwideweb</title>
<author>ditel&ditel</author>
<ISBN>123-456-781</ISBN>
<publisher>person</publisher>
<edition>3</edition>
<price>450</price>
</book>
</bookstore>
DEPARTMENT OF CSE 25
WEB TECHNOLOGIES LAB MRCET
Bookstore.xml
<!DOCTYPE bookstore SYSTEM "C:\Documents and Settings\Administrator\My
Documents\bookstore.dtd">
<bookstore>
<book>
<title>web programming</title>
<author>chrisbates</author>
<ISBN>123-456-789</ISBN>
<publisher>wiley</publisher>
<edition>3</edition>
<price>350</price>
</book>
<book>
<title>internet worldwideweb</title>
<author>ditel&ditel</author>
<ISBN>123-456-781</ISBN>
<publisher>person</publisher>
<edition>3</edition>
<price>450</price>
</book>
</bookstore>
DEPARTMENT OF CSE 26
WEB TECHNOLOGIES LAB MRCET
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Bookstore.xml
<bookstore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\Documents and Settings\Administrator\My
Documents\bookstore.xsd">
<book>
<title>web programming</title>
<author>chrisbates</author>
<ISBN>123-456-789</ISBN>
<publisher>wiley</publisher>
<edition>3</edition>
<price>350</price>
</book>
<book>
<title>internet worldwideweb</title>
<author>ditel&ditel</author>
<ISBN>123-456-781</ISBN>
<publisher>person</publisher>
<edition>3</edition>
<price>450</price>
</book>
</bookstore>
PROGRAM:
XML:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="bookstore.xsl"?>
<bookstore>
<book>
<title>Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
DEPARTMENT OF CSE 27
WEB TECHNOLOGIES LAB MRCET
</book>
<book>
<title>Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2> My Books collection</h2>
<table border="1">
<tr bgcolor="red">
<th align="left">title</th>
<th align="left">author</th>
</tr>
<xsl:for-each select="bookstore/book">
<tr>
<td><xsl:value-of select="title"/></td>
<xsl:choose>
<xsl:when test="price > 30">
<td bgcolor="yellow"><xsl:value-of select="author"/></td>
</xsl:when>
<xsl:when test="price > 10">
<td bgcolor="magneta"><xsl:value-of select="author"/></td>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="author"/></td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
DEPARTMENT OF CSE 28
WEB TECHNOLOGIES LAB MRCET
OUTPUT:
DEPARTMENT OF CSE 29
WEB TECHNOLOGIES LAB MRCET
WEEK - 8:
Develop and demonstrate PHP Script for the following problems:
a) Write a PHP Program to display current Date, Time and Day.
b) Write a PHP Script to check whether the given number is palindrome or not.
c) A web application that takes name and age from an HTML page. If the age is less than 18, it
should send a page with “Hello <name>, you are not authorized to visit the site” message,
where <name> should be replaced withthe entered name. Otherwise it should send
“Welcome <name> to this site” message
Program:
a) Write a PHP Program to display current Date, Time and Day.
<?php
date_default_timezone_set ("Asia/Calcutta");
echo "Date: ";
echo date("d/m/y");
echo "<br> Time: ";
echo date(" H:i:s A",
time());echo "<br> Day: ";
$day=date("l");
echo $day;
?>
Output:
DEPARTMENT OF CSE 30
WEB TECHNOLOGIES LAB MRCET
if($t==$rev)
echo "$rev is a
Palindrome";else
echo "$rev is not a Palindrome";
?>
Output:
DEPARTMENT OF CSE 31
WEB TECHNOLOGIES LAB MRCET
C) A web application that takes name and age from an HTML page. If the age is less
than 18, it should send a page with “Hello <name>, you are not authorized to visit
the site” message, where <name> should be replaced with the entered name.
Otherwise it should send “Welcome <name> to this site” message.
checkage.html
<html>
<body bgcolor="bisque">
<form action='home.php' method='post'>
<center><b><font color="blue" size="10">Login</font></b></center><br><br>
User name: <input type='text' name='name'><br>
age: <input type='text' name='age'><br>
<input type='submit'value='Login'>
</form>
</body>
</html>
home.php
<?php
$name = $_POST['name'];
$age =
$_POST['age'];if
($age < 18)
print "Hello " . $name . " you are not authorized to visit this
site.";else
print "Welcome " . $name . " to this site."
?>
Output:
DEPARTMENT OF CSE 32
WEB TECHNOLOGIES LAB MRCET
WEEK - 9:
Implement the following web applications using Servlets
a) A web application that takes a name as input and on submit it shows a hello
<name> page where name is taken from the request. It shows the start time at the right
top corner of the page and provides a logout button. On clicking this button, it should
show a logout page with Thank You <name > message with the duration of usage (hint:
Use session to store name and time).
b) Write a PHP Program to display current Date, Time and Day.
c) A web application that takes name and age from an HTML page. If the age is less
than 18, it should send a page with “Hello <name>, you are not authorized to visit
the site” message, where <name> should be replaced with the entered name.
Otherwise it should send “Welcome <name> to this site” message.
Program: a)
Session1.html
<html>
<head> <title> SESSION LOGIN </title> </head>
<body>
<center>
<form action="http://localhost:8080/Session1/session6vib"
method="get">Enter Name: <input type="text" name="uname"> <br>
<input type="submit" value="LOGIN" name="register">
</form>
</center>
</body>
</html>
Session1.java
import javax.servlet.*;
import
javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Session1 extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
IOException, ServletException
{
try
{
res.setContentType("text/ht
ml");PrintWriter
out=res.getWriter();
out.println("<form method=get
action=session26vib>");Date d=new Date();
out.println("<p align=right> Time:"+d.getTime()+"</p>");
String un=req.getParameter("uname");
HttpSession session=req.getSession();
DEPARTMENT OF CSE 33
WEB TECHNOLOGIES LAB MRCET
session.setAttribute("user",un);
session.setAttribute("time",d.getTime());
out.println("Hello\t"+un);
out.println("<br><br> <input type=submit
value=logout>");out.println("</form");
}
catch(Exception e)
{
e.printStackTrace();
}
} }
Session2.java
import javax.servlet.*;
import
javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Session2 extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
IOException, ServletException
{
try
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
HttpSession
session=req.getSession();Date
d2=new Date();
String
un=(String)session.getAttribute("user");
Long
t1=(Long)session.getAttribute("time");
Long t2=d2.getTime();
session.invalidate();
out.println("Thank
you\t"+un);
out.println("<br><br> Session duration: '"+(t2-t1)/(60*60)+"'seconds");
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
web.xml
<?xml version="1.0"?>
<web-app>
DEPARTMENT OF CSE 34
WEB TECHNOLOGIES LAB MRCET
<servlet>
<servlet-name>session1</servlet-name>
<servlet-class>Session1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>session1</servlet-name>
<url-pattern>/session6vib</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>session2</servlet-name>
<servlet-class>Session2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>session2</servlet-name>
<url-pattern>/session26vib</url-pattern>
</servlet-mapping>
</web-app>
Output:
DEPARTMENT OF CSE 35
WEB TECHNOLOGIES LAB MRCET
b)
DateSrv.java
import java.io.*;
import
javax.servlet.*;
public class DateSrv extends GenericServlet
{
//implement service()
public void service(ServletRequest req, ServletResponse res) throws
IOException, ServletException
{
//set response content type
res.setContentType("text/ht
ml");
//get stream obj
PrintWriter pw = res.getWriter();
//write req processing logic
java.util.Date date = new java.util.Date();
pw.println("<h2>"+"Current Date & Time: " +date.toString()+"</h2>");
//close stream
object
pw.close();
}
}
web.xml
<?xml version="1.0"?>
<web-app>
<servlet>
<servlet-name>Date</servlet-name>
<servlet-class>DateSrv</servlet-class>
</servlet>
<servlet-mapping>
DEPARTMENT OF CSE 36
WEB TECHNOLOGIES LAB MRCET
<servlet-name>Date</servlet-name>
<url-pattern>/date</url-pattern>
</servlet-mapping>
</web-app>
Output:
c)
index.html:
<html
<head>
<title>VoterApp</title>
</head>
<body>
<form action= "http://localhost:8080/CheckAge/check" method="get">
<fieldset style="width:20%; background-color:#80ffcc">
<table>
<tr><td>Name</td><td><input type="text" name="name"></td></tr>
<tr><td>Age</td><td><input type="text" name="age"></td></tr>
<tr><td></td>
<td><input type = "submit" value="Check Eligibility"></td></tr>
</table>
</fieldset>
</form>
</body>
</html>
VoterSrv.java:
import java.io.*;
import java.util.*;
import
javax.servlet.*;
import javax.servlet.http.*;
public class VoterSrv extends HttpServlet
{
public void service(HttpServletRequest req, HttpServletResponse res)
throwsIOException,ServletException
{
//set response content type
res.setContentType("text/ht
DEPARTMENT OF CSE 37
WEB TECHNOLOGIES LAB MRCET
ml");
//get printWrite obj
PrintWriter pw = res.getWriter();
//read form data from page as request
parameter String name =
req.getParameter("name");
int age =
Integer.parseInt(req.getParameter("age")); if
(age>=18)
{
pw.println("<font color='green' size='4'>Welcome "+name+" to this site</font>");
}
else
pw.println("<font color='red' size='4'>Hello "+name+", you are not
authorized to visit the site</font>");
//add hyperlink to dynamic page
pw.println("<br><br><a href=
'index.html'>back</a>");
//close the
stream
pw.close();
}
}
web.xml:
<web-app>
<servlet>
<servlet-name>abc</servlet-name>
<servlet-class>VoterSrv</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>abc</servlet-name>
<url-pattern>/check</url-pattern>
</servlet-mapping>
</web-app>
Output:
DEPARTMENT OF CSE 38
WEB TECHNOLOGIES LAB MRCET
DEPARTMENT OF CSE 39
WEB TECHNOLOGIES LAB MRCET
WEEK - 10:
Execute simple queries with Database using a) PHP, b) Servlets
PROGRAM:
db.php
<html>
<body>
<?php
$severname="localhost";
$username="root";
$password="TIGER";
$conn=new
mysqli($severname,$username,$password);
if($conn->connect_error)
{
die("connection failed".$conn->connect_error);
}
echo "Connected successfully <br>";
//Create database
$sql = "CREATE DATABASE reg";
if(mysqli_query($conn,$sql))
echo "Database created
successfully<br>";else
echo "error";
$servername="localhost";
$dbname="reg";
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check
connectionif
(!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully <br>";
// sql to create table
$sql = "CREATE TABLE Guests (
name VARCHAR(30) NOT
NULL, pwd VARCHAR(30) NOT
NULL)";
if (mysqli_query($conn, $sql))
{
echo "Table MyGuests created successfully<br>";
}
else {
echo "Error creating table: " . mysqli_error($conn);
}
$sql = "INSERT INTO Guests (name, pwd) VALUES ('cse', '5')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
}
DEPARTMENT OF CSE 40
WEB TECHNOLOGIES LAB MRCET
else
{
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
?>
</body>
</html>
Output of db.php:
Login.html
<html>
<head> <title> Login Page </title> </head>
<body>
<center> <h1> Login Page </h1>
<form action="loginform.php" method="post">
<table>
<tr> <td> <label> Name: </label> </td>
<td> <input type="text" name="uname" /> </td>
</tr>
<tr> <td> <label> Password: </label> </td>
<td> <input type="password" name="upwd" /> </td>
</tr>
<tr> <td> <input type="submit" value="submit" /> </td>
<td> <input type="reset" value="reset" /> </td>
</tr>
</table>
</form>
</center>
</body>
</html>
loginform.php
<html>
<head> <title> Registration page </title> </head>
<body>
DEPARTMENT OF CSE 41
WEB TECHNOLOGIES LAB MRCET
<?php
$name=$_POST["uname"];
$pwd=$_POST["upwd"];
$conn=mysql_connect("localhost","root","TIGER") or
die("mysql_error()");mysql_select_db("reg") or die("mysql_error()");
$query=mysql_query("SELECT * from guests where
name='$name'");while($row=mysql_fetch_array($query))
{
$duser=$row['name'];
$dpwd=$row['pwd'];
}
if($pwd==$dpwd &&
$name==$duser) echo "welcome
$name branch";
else
echo "invalid user";
?>
</body>
</html>
OUTPUT:
DEPARTMENT OF CSE 42
WEB TECHNOLOGIES LAB MRCET
B) USING SERVLET
DBExample.java
import java.io.*;
import
javax.servlet.*;
import
javax.servlet.http.*;
import java.util.*;
import java.sql.*;
public class DBExample extends HttpServlet{
public void doGet(HttpServletRequest
request,
HttpServletResponse response)
throws ServletException,
IOException
{
String
JDBC_DRIVER="com.mysql.jdbc.Driver";
String
DB_URL="jdbc:mysql://localhost/csec";
String USER = "root";
String PASS = "TIGER";
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><body><h1>Welcome to
MRCET</h1>\n") ;try{
Class.forName("com.mysql.jdbc.Driver");
Connection conn =
DriverManager.getConnection(DB_URL, USER, PASS);
Statement stmt =
conn.createStatement();String sql;
sql = "SELECT * FROM Emp";
ResultSet rs =
stmt.executeQuery(sql);
while(rs.next()){
out.println("ID: " + rs.getString(1));
out.println("Age: " + rs.getString(2));
out.println("First Name: " +
rs.getString(3)+"<br>");
}
rs.close();
stmt.close();
conn.close();
}catch(SQLException se){
out.println(se.getMessage());
}catch(Exception e){
out.println(e.getMessag
e());
DEPARTMENT OF CSE 43
WEB TECHNOLOGIES LAB MRCET
}
out.println("</body></html>");
}
}
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<servlet>
<servlet-name>DBExample</servlet-name>
<servlet-class>DBExample</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DBExample</servlet-name>
<url-pattern>/db</url-pattern>
</servlet-mapping>
</web-app>
OUTPUT:
DEPARTMENT OF CSE 44
WEB TECHNOLOGIES LAB MRCET
WEEK - 11:
Implement the following web applications using JSP
i) Write a PHP Program to display current Date, Time and Day.
ii) A web application that takes name and age from an HTML page. If the age is less than 18,
it should send a page with “Hello <name>, you are not authorized to visit the site”
message, where <name> should be replaced withthe entered name. Otherwise it should
send “Welcome <name> to this site”message.
iii) Write a program for deploying Java Beans in a JSP page.
Program
i) test.jsp
<html>
<head><title>JSPApp</title></head>
<body>
<form>
<fieldset style="width:50%; background-color: #ccffeb;">
<legend><b><i>JSP Application<i><b></legend>
<h3>Current Date and Time is :</h3>
<% java.util.Date d = new
java.util.Date();
out.println(d.toString()); %>
</fieldset>
</form>
</body>
</html>
Output:
DEPARTMENT OF CSE 45
WEB TECHNOLOGIES LAB MRCET
ii) UserEligibility.html:
<html>
<head> <title> User Acess </title> </head>
<body> <br>
<center>
<h1> USER ELIGIBILITY </h1>
<form action="http://localhost:8080/jsp/checkage.jsp" method="get">
<input type="text" name="uname" placeholder="Enter your name"> <br>
<input type="text" name="uage" placeholder="Enter your age"> <br>
<input type="submit" value="submit" name="sub"<>
</form>
</center>
</body>
</html>
checkage.jsp:
<%@page language="java" import="java.sql.*" errorPage=""%>
<%
String
name;int
age;
name=request.getParameter("uname");
age=Integer.parseInt(request.getParameter("uage"));
if(age<=18)
{
out.println("<h1> Hello\t " +name+"\t you are not eligible </h1>");
}
else
{
out.println("<h1> Welcome " +name+" to this site </h1>");
}
%>
Output:
DEPARTMENT OF CSE 46
WEB TECHNOLOGIES LAB MRCET
DEPARTMENT OF CSE 47
WEB TECHNOLOGIES LAB MRCET
iii). SampleBean.java
package com.javacodegeeks.snippets.enterprise;
import java.util.Date;
UseBean.jsp
<html>
<head>
<title>Java Code Geeks Snippets - Use a Bean in JSP Page</title>
</head>
<body>
DEPARTMENT OF CSE 48
WEB TECHNOLOGIES LAB MRCET
</body>
URL:
http://myhost:8080/jcgsnippets/UseBean.jsp
Output:
Sample Bean: SampleBean [param1=value1, param2=Thu Nov 17 21:28:03 EET 2011]
DEPARTMENT OF CSE 49
WEB TECHNOLOGIES LAB MRCET
WEEK - 12:
Write a program to design a simple calculator using (a) JavaScript (b)PHP (c) Servlet and (d) JSP
DEPARTMENT OF CSE 50
WEB TECHNOLOGIES LAB MRCET
OUTPUT:
DEPARTMENT OF CSE 51
WEB TECHNOLOGIES LAB MRCET
add.php
<?php
$a = $_POST['t1'];
$b = $_POST['t2'];
if (isset($_POST['add']))
{
$c = $a + $b;
print $a . "+" . $b . "=" . $c;
}
if (isset($_POST['sub']))
{
$c = $a - $b;
print $a . "-" . $b . "=" . $c;
}
if (isset($_POST['mul']))
{
$c = $a * $b;
print $a . "*" . $b . "=" . $c;
}
if (isset($_POST['div']))
{
$c = $a / $b;
print $a . "/" . $b . "=" . $c;
}
?>
Output:
DEPARTMENT OF CSE 52
WEB TECHNOLOGIES LAB MRCET
DEPARTMENT OF CSE 53
WEB TECHNOLOGIES LAB MRCET
if(op.equals("+")){pw.println("Addition
:::"+(n1+n2));}
else if(op.equals("-")){pw.println("Subtraction :::"+(n1-n2));}
else if(op.equals("*")){pw.println("Multiplication :::"+(n1*n2));}
else if(op.equals("/")){pw.println("Division
:::"+(n1/n2));}else{pw.println("Remainder
:::"+(n1%n2));}
pw.close();
}
}
web.xml
<web-app>
<servlet>
<servlet-name>Calculator</servlet-name>
<servlet-class>Cal</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Calculator</servlet-name>
<url-pattern>/calc</url-pattern>
</servlet-mapping>
</web-app>
Output:
DEPARTMENT OF CSE 54
WEB TECHNOLOGIES LAB MRCET
DEPARTMENT OF CSE 55
WEB TECHNOLOGIES LAB MRCET
int mul=num1*num2;
out.println("multiplication is: "+mul);
}
else if(operation.equals("div"))
{
int div = num1/num2;
if(num1>=num2)
out.println("division is:
"+div);else
out.println("The division cannot be performed");
}
%>
</body>
</html>
OUTPUT:
DEPARTMENT OF CSE 56
WEB TECHNOLOGIES LAB MRCET
DEPARTMENT OF CSE 57