Lab Manual Web Engineering
Lab Manual Web Engineering
Lab Manual Web Engineering
2019
WEB ENGINEERING LAB MANUAL- CS-7003
Prepared By:
Er.Jitendra Tiwari
Assistant Professor
AITRC, Cwa
.
Name:
USN:
Batch: Section:
.
SYLLABUS
WEB ENGINEERING LABORATORY
1. Develop and demonstrate a XHTML file that includes Javascript script for the following
problems:
a)Input: A number n obtained using prompt
Output: The first n Fibonacci numbers
b) Input: A number n obtained using prompt
Output: A table of numbers from 1 to n and their squares using alert
2. a) Develop and demonstrate, using Javascript script, a XHTML document that collects the
USN ( the valid format is: A digit from 1 to 4 followed by two upper-case characters followed by
two digits followed by two upper-case characters followed by three digits;no embedded spaces
allowed) of the user. Event handler must be included for the form element that collects this
information to validate the input. Messages in the alert windows must be produced when errors
are detected.
b) Modify the above program to get the current semester also (restricted to be a number from 1
to 8)
3. a) Develop and demonstrate, using Javascript script, a XHTML document that contains three
short paragraphs of text, stacked on top of each other, with only enough of each showing so that
the mouse cursor can be placed over some part of them. When the cursor is placed over the
exposed part of any paragraph, it should rise to the top to become completely visible.
b) Modify the above document so that when a paragraph is moved from the top stacking
Position, it returns to its original position rather than to the bottom.
5. a) Write a Perl program to display various Server Information like Server Name, Server
Software, Server protocol, CGI Revision etc.
b) Write a Perl program to accept UNIX command from a HTML form and to display the
output of the command executed.
6. a) Write a Perl program to accept the User Name and display a greeting message randomly
chosen from a list of 4 greeting messages.
b) Write a Perl program to keep track of the number of visitors visiting the web page and to
display this count of visitors, with proper headings.
7. Write a Perl program to display a digital clock which displays the current time of the server.
8. Write a Perl program to insert name and age information entered by the user into a table
created using MySQL and to display the current contents of this table.
9. Write a PHP program to store current date-time in a COOKIE and display the ‘Last visited on’
date- time on the web page upon reopening of the same page.
10. Write a PHP program to store page views count in SESSION, to increment the count on each
refresh, and to show the count on web page.
11. Create a XHTML form with Name, Address Line 1, Address Line 2, and E-mail text fields.
On submitting, store the values in MySQL table.Retrieve and display the data based on Name.
12. Using PHP and MySQL, develop a program to accept book information viz. Accession
number, title, authors, edition and publisher from a web page and store the information in a
database and to search for a book with the title specified by the user and to display the search
results with proper headings.
NOTE: Student is required to solve one problem in the examination. The questions are allotted
based on lots.
CONTENTS
1 Develop and demonstrate a XHTML file that includes Javascript script for
the following problems:
a)Input: A number n obtained using prompt
Output: The first n Fibonacci numbers
b) Input: A number n obtained using prompt
Output: A table of numbers from 1 to n and their squares using alert
2 Develop and demonstrate, using Javascript script, a XHTML document
that collects the USN ( the valid format is: A digit from 1 to 4 followed by
two upper-case characters followed by two digits followed by two upper-
case characters followed by three digits;no embedded spaces allowed) of
the user. Event handler must be included for the form element that collects
this information to validate the input. Messages in the alert windows must
be produced when errors are detected.
b) Modify the above program to get the current semester also (restricted
to be a number from 1 to 8)
3 Develop and demonstrate, using Javascript script, a XHTML document
that contains three short paragraphs of text, stacked on top of each other,
with only enough of each showing so that the mouse cursor can be placed
over some part of them. When the cursor is placed over the exposed part of
any paragraph, it should rise to the top to become completely visible.
b) Create an XSLT style sheet for one student element of the above
document and use it to create a display of that element.
5 Write a Perl program to display various Server Information like Server
Name, Server Software, Server protocol, CGI Revision etc.
8 Write a Perl program to insert name and age information entered by the
user into a table created using MySQL and to display the current contents
of this table.
9 Write a PHP program to store current date-time in a COOKIE and display
the ‘Last visited on’ date- time on the web page upon reopening of the
same page.
10 Write a PHP program to store page views count in SESSION, to increment
the count on each refresh, and to show the count on web page.
11 Create a XHTML form with Name, Address Line 1, Address Line 2, and
E-mail text fields. On submitting, store the values in MySQL
table.Retrieve and display the data based on Name.
A)
<html xmlns="http://www.w3.org/1999/xhtml/">
<head><title>Fibonacci Series</title>
</head>
<body bgcolor="yellow">
<script type="text/javascript">
var f1=0;
var f2=1;
if(limit == 1)
document.write("",f1,"<br/>");
if(limit == 2)
document.write("",f1,"<br/>");
document.write("",f2,"<br/>");
}
if(limit > 2)
document.write("",f1,"<br/>");
document.write("",f2,"<br/>");
for(i=2;i<limit;i++)
f3 = f2+f1;
document.write("",f3,"<br/>");
f1=f2;
f2=f3;
</script>
</body>
</html>
B)
<?xml version ="1.0" encoding = "utf-8?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body style="background-color:yellow">
res = x * x;
msg = msg + " "+ x + " * "+ x + " = " + res + "\n";
alert(msg);
</script>
</body>
</html>
Program 02:
. Develop and demonstrate, using Javascript script, a XHTML document that collects the USN (
the valid format is: A digit from 1 to 4 followed by two upper-case characters followed by two
digits followed by two upper-case characters followed by three digits;no embedded spaces
allowed) of the user. Event handler must be included for the form element that collects this
information to validate the input. Messages in the alert windows must be produced when errors
are detected.
b) Modify the above program to get the current semester also (restricted to be a number from 1
to 8)
A)
<html xmlns="http://www.w3.org/1999/xhtml/">
<head><title>USN.html</title>
<script type="text/javascript">
function checkusn()
alert("CIT");
var str=document.getElementById("usn");
alert(str);
var result=str.value.search(/^[1-4]{1}[A-Z]{2}\d{2}[A-Z]{2}\d{3}$/);
alert(result);
if(result != 0)
else
</script>
</head>
<body style="background-color:yellow">
<br/>
<br/>
<br/>
</form>
</body>
</html>
B)
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml/">
<head><title>USN.html</title>
<script type="text/javascript">
function validate()
var str=document.getElementById("usn");
else
</script>
</head>
<body style="background-color:yellow">
<br/>
<br/>
<br/>
<br/>
<br/>
</form>
</body>
</html>
Program 03:
Develop and demonstrate, using Javascript script, a XHTML document that contains three short
paragraphs of text, stacked on top of each other, with only enough of each showing so that the
mouse cursor can be placed over some part of them. When the cursor is placed over the exposed
part of any paragraph, it should rise to the top to become completely visible.
b) Modify the above document so that when a paragraph is moved from the top stacking
position, it returns to its original position rather than to the bottom.
A)
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.layer1Style
padding: 1em;
width:300px;
background-color:green;
position:absolute;
top:100px;
left:200px;
z-index:0;
.layer2Style
padding: 1em;
width:300px;
background-color:BLUE;
position:absolute;
top:120px;
left:220px;
z-index:0;
.layer3Style
padding: 1em;
width:300px;
background-color:purple;
position:absolute;
top:140px;
left:240px;
z-index:0;
</style>
<script type="text/javascript">
var topLayer="layer3";
function mover(toTop)
var oldTop=document.getElementById(topLayer).style;
var newTop=document.getElementById(toTop).style;
oldTop.zIndex="0";
newTop.zIndex="10";
topLayer=document.getElementById(toTop).id;
alert(topLayer);
</script>
</head>
onmouseover="mover('layer1')">
advent of WWW.
</div>
onmouseover="mover('layer2')">
The www may seem like magic , untill you undrestand how it
</div>
onmouseover="mover('layer3')">
</div>
</body> </html>
B)
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.layer1Style{
padding: 1em;
width:300px;
background-color:green;
position:absolute;
top:100px;
left:400px;
z-index:1;
.layer2Style{
padding: 1em;
width:300px;
background-color:red;
position:absolute;
top:120px;
left:420px;
z-index:2;
.layer3Style{
width:300px;
background-color:orange;
position:absolute;
top:140px;
left:440px;
z-index:3;
</style>
<script type="text/javascript">
var topLayer="layer3";
var origPos;
function mover(toTop,pos)
var newTop=document.getElementById(toTop).style;
newTop.zIndex="10";
topLayer=document.getElementById(toTop).id;
origPos=pos;
function moveBack()
document.getElementById(topLayer).style.zIndex=origPos;
</script>
</head>
<body style="background-color:yellow">
position.</h1>
onmouseover="mover('layer1','1')" onmouseout="moveBack()">
</div>
onmouseover="mover('layer2','2')" onmouseout="moveBack()">
The www may seem like magic , untill you undrestand how it works.The Web is
</div>
onmouseover="mover('layer3','3')" onmouseout="moveBack()">
Windows XP provides many ways for you to communicate with friends, coworkers,
</div>
</body>
</html>
Program 04:
b) Create an XSLT style sheet for one student element of the above document and use it to
create a display of that element.
A)
<!DOCTYPE student[
<!ELEMENT ad (usn,name,collegename,branch,year,email)>
<!ELEMENT h3 (#PCDATA)>
<!ELEMENT h2 (#PCDATA)>
]>
<student_information>
<h3>Student-Information</h3>
</student_information>
Stu.css
h3{color;red; font-size:16pt; }
B)
<?xml version ="1.0" encoding="utf-8"?>
<!DOCTYPE student[
<!ELEMENT ad (usn,name,collegename,branch,year,email)>
]>
<student>
<email> abc@gmail.com</email>
</student>
Xslstudent.xsl
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
</xsl:template>
</xsl:stylesheet>
Program 05:
Write a Perl program to display various Server Information like Server Name, Server Software,
Server protocol, CGI Revision etc.
b) Write a Perl program to accept UNIX command from a HTML form and to display the
output of the command executed
A)
#!/usr/bin/perl
"<html>",
"<h1>Welcome to CIT</h1>",
"<body>",
"</html>";
B)
#!/usr/bin/perl
use CGI':standard';
header(),
start_html(-title=>'UNIX COMMAND',-bgcolor=>'#00ffff'),
hr(),
startform(-method=>'get',-action=>'./lab5b.cgi'),
br(),
submit(-value=>'EXECUTE'),
endform(),
hr(),
'$',$cmd=param("cmd"),
br(),
pre(`$cmd`),
end_html();
Program 06:
Write a Perl program to accept the User Name and display a greeting message randomly chosen
from a list of 4 greeting messages.
b) Write a Perl program to keep track of the number of visitors visiting the web page and to
display this count of visitors, with proper headings
A)
#!/usr/bin/perl
use ;
‟
d
r
a
n
t
s
:
I
G
Cprint
header(),
start_html(-title=>‟GREETING‟,-bgcolor=>‟brown‟),
h1({-align=>‟center‟},‟USER GREETING‟),
hr,
font({-color=>‟lightblue‟,-weight=>‟bold‟,-size=>‟5‟},‟ENTER THE R
E
S
UAME
N
HERE‟),
br,
start_form(-action=>‟./6a.cgi‟),
textfield(-name=>‟name‟),
submit(-value=>‟SEND‟),
end_form(),
hr,
font({-color=>‟yellow‟,-size=>‟5‟},‟DEAR USER‟),
font({-color=>‟white‟,-size=>‟8‟},$username=param(„name‟),
br);
@msgs=(“GOOD”,”BAD”,”HELLO”,”HELL”);
hr,
end_html;
B)
#!/usr/bin/perl
use ;
‟
d
r
a
n
t
s
:
I
G
Cprint
header(),
start_html(-bgcolor=>‟lightyellow‟),
hr,
font({-color=>‟lightblue‟,-size=>‟4‟},‟This page is ,
)
‟
d
e
t
i
s
vbr,
font({-color=>‟orange‟,-size=>‟7‟},`grep „/cgi-bin/6b.cgi‟ g
o
l
s
e
c
a wc –l`),
|
br,
font({-color=>‟lightblue‟,-size=>‟4‟},‟no of ,
)
‟
s
e
m
i
tbr,
hr,
end_html;
ln /var/log/httpd/access_log accesslog
Program 07:
Write a Perl program to display a digital clock which displays the current time of the server.
#!/usr/bin/perl
($sec,$min,$hr)=localtime();
header(),
start_html(-title=>'digital clock',-bgcolor=>'#00ffff'),
h1({-align=>'center'},'DIGITAL CLOCK'),
hr(),
h1({-align=>'center'},b("$hr:$min:$sec")),
hr(),
end_html();
Program 08:
Write a Perl program to insert name and age information entered by the user into a table created
using MySQL and to display the current contents of this table.
#!/usr/bin/perl
use CGI':standard';
use DBI;
print header(),
start_html(-title=>'database access',-bgcolor=>'#00ffff'),
h1({-align=>'center'},'Database Access'),
hr(),
h2({-align=>'center'},'Database insert'),
start_form(-action=>‟./8.cgi‟),
„NAME:‟,
textfield(-name=>‟name‟),
br,
„AGE:‟,
textfield(-name=>‟age‟),br,
submit(-value=>‟Insert‟),
reset(-value=>‟Reset‟),
end_form(),
hr();
$ename = param(„name‟);
$eage = param(„age‟);
if($ename eq “”)
{
else
hr(),
h2({-align=>'center'},'Database display'),
pre(
„userinfo‟
br(),
„-‟x 50,br(),
„NAME AGE‟,br(),
„-‟x 50);
$st1->execute();
while(($ename,$eage)=$sth1->fetchrow())
$sth1->finish();
$sth->finish();
$dbh->disconnect;
end_html();
Program 09:
Write a PHP program to store current date-time in a COOKIE and display the ‘Last visited on’
date- time on the web page upon reopening of the same page.
<?php
setcookie("lastvisit",date("h:i-m/d/y"),time()+60*60);
?>
<html>
<body bgcolor=”lightyellow”>
<font size=20pt>
<hr>
<?
if(isset($_COOKIE["lastvisit"]))
echo “</p></font>”;
else
?>
Program 10:
Write a PHP program to store page views count in SESSION, to increment the count on each
refresh, and to show the count on web page.
<?php
session_start();
?>
<html>
<body bgcolor=”lightyellow”>
<hr>
<hr>
<?
if(isset($_SESSION['views']))
$_SESSION['views'] = $_SESSION['views']+ 1;
else
$_SESSION['views'] = 1;
?>
<font size=20pt,color=red>
<?
echo $_SESSION['views']
?>
</font><br>
<i><b>Times</b></i>
</body>
</html>
Program 11:
Create a XHTML form with Name, Address Line 1, Address Line 2, and E-mail text fields. On
submitting, store the values in MySQL table. Retrieve and display the data based on Name.
INSERT FORM
<html xmlns="http://www.w3.org/1999/xhtml">
<body bgcolor="lightyellow">
<tr>
</tr>
<tr>
<tr>
<td>
<table border="1">
<tr>
<td>Name:</td>
</tr>
<tr>
<td>ADDRESS1:</td>
</tr>
<tr>
<td>ADDRESS2:</td>
</tr>
<tr>
<td>EMAIL:</td>
</tr>
<tr>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
SEARCH FORM
<html>
<head>
</head>
<html>
<table>
<tr>
<td>
</td>
</tr>
</table>
</body>
</html>
Program 12:
Using PHP and MySQL, develop a program to accept book information viz. Accession number,
title, authors, edition and publisher from a web page and store the information in a database and
to search for a book with the title specified by the user and to display the search results with
proper headings.
13.php
<?php
?>
<html>
<?php
$name = $_REQUEST["name"];
$add1 = $_REQUEST["add1"];
$add2 = $_REQUEST["add2"];
$email = $_REQUEST["email"];
if($name == NULL && $add1 == NULL && $add2 == NULL && $email == NULL)
else
?>
</table>
</body>
</html>
13a.php
<?php
?>
<html>
<body bgcolor="lightyellow">
<?php
$name1 = $_REQUEST["name1"];
if($name1==NULL)
else
echo "<hr>";
<tr>
<td>Name:</td>
<td>Address1:</td>
<td>Address2:</td>
<td>Email:</td>
</tr>";
while($array = mysql_fetch_row($result1))
echo "<tr>
<td>$array[0]</td>
<td>$array[1]</td>
<td>$array[2]</td>
<td>$array[3]</td>";
echo "</table>";
echo "<hr>";
?>
</body>
</html>
12. RUBY ON RAILS
4. Create the controller file by using the command => ruby script/generate controller main
5. Create the database by name books_development and the table by the name books or use the
db migrate command
6. Create the front end forms for insert and search and the result forms and save it in the directory
/app/views/main/
7. Write the controller code in file named /app/controllers/main_controller.rb.
8. Start the server by using the command ruby script/server
dbinsert.rhtml
<html>
<head><title>DBINSERT</title></head>
<body bgcolor="lightyellow">
<hr />
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</td>
</tr>
</table>
<hr>
</form>
</body>
</html>
resultinsert.rhtml
<html>
<body bgcolor="lightyellow">
</h1>
<hr />
</body>
</html>
dbsearch.rhtml
<html>
<body bgcolor="lightyellow">
<hr />
<tr>
</tr>
<tr>
</td>
</tr>
</table>
<hr>
</form>
</body>
</html>
searchresult.rhtml
<html>
<head>
<body bgcolor="lightyellow">
<hr>
<tr>
</tr>
@title = boo.title
@author = boo.author
@edition = boo.edition
<tr>
<td><%= @publication%></td>
</tr>
</table>
</body>
</html>
main_controller.rb
def resultinsert
@book = Book.new(params[:book])
if @book.save
else
end
end
def searchresult
@titlename = params[:title]
end
end