Web Technology Lab Manual Updated (1)
Web Technology Lab Manual Updated (1)
(CS2208)
LABORATORY MANUAL & RECORD
B.Tech (Common for CSE II YEARS)
(With effect from 2022-23 admitted batches)
(II YEAR- IISEM)
MISSION
To impart high standard value-based technical education in all aspects of Computer
Science and Engineering through the state of the art infrastructure and innovative
approach.
To produce ethical, motivated, and skilled engineers through theoretical knowledge
and practical applications.
To impart the ability for tackling simple to complex problems individually as well
as in a team.
To develop globally competent engineers with strong foundations, capable of “out of
the box” thinking so as to adapt to the rapidly changing scenarios requiring socially
conscious green computing solutions.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)
Graduates of B. Tech in computer science and Engineering Programme shall be able to
PEO1: Strong foundation of knowledge and skills in the field of Computer Science and
Engineering.
PEO2: Provide solutions to challenging problems in their profession by applying computer
engineering theory and practices.
PEO3: Produce leadership and are effective in multidisciplinary environment.
COURSE OBJECTIVES
To facilitate the graduates with the ability to visualize, gather
information, articulate, analyze, solve complex problems, and make
decisions. These are essential to address the challenges of complex
and computation intensive problems increasing their productivity.
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.
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
CS2208 WEB TECHONOLOGIES
Syllabus
1. Design the following static web pages required for an online book store web site.
a) HOME PAGE: The static home page must contain three frames.
b) LOGIN PAGE
c) CATOLOGUE PAGE: The catalogue page should contain the details
of all the books available in the web site in a table.
d) REGISTRATION PAGE
2. Write JavaScript to validate the following fields of the Registration page.
a) First Name (Name should contains alphabets and the length should not be less
than 6 characters).
b) Password (Password should not be less than 6 characters length).
c) E-mail id (should not contain any invalid and must follow the standard
pattern name@domain.com)
d) Mobile Number (Phone number should contain 10 digits only).
e) Last Name and Address (should not be Empty).
3. Develop and demonstrate the usage of inline, internal and external style sheet
using CSS
4. Develop and demonstrate JavaScript with POP-UP boxes and functions
for the following problems:
a) Input: Click on Display Date button using onclick( )
1 Design the following static web pages required for an online book store 1-8
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 books available in the web site in a table.
4) REGISTRATION PAGE
3 Develop and demonstrate the usage of inline, internal and external 15-17
style sheet using CSS
Develop and demonstrate PHP Script for the following problems: 25-26
7 a) Write a PHP Script to find out the Sum of the Individual Digits.
b) Write a PHP Script to check whether the given number is
Palindrome or not
A web application that lists all cookies stored in the browser on clicking
iv “List Cookies” button. Add cookies if necessary.
52-57
10 Implement the web applications with Database using
(a) PHP, (b) Servlets and (c) JSP.
11 58-59
Modify the above PHP program to use an xml instead of database
60-67
12 Write a program to design a simple calculator using (a) JavaScript (b)
PHP (c) Servlet and (d) JSP.
WEB TECHNOLOGIES LAB
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 books
available 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 page
and 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 Contains
the 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 is
used 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 ">
<img src="images/logo1.png" width="125" height="115" align="left">
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>
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>
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:Oxford
University 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>
</table> </form>
</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. smith@hotmail.com</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 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:
EXERCISE:
1. Create your class time table in a webpage.
2. Design the static web pages required for an online shopping cart.
</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. smith@hotmail.com</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 type='radio' name="gender">female<br/><br />
<input type='Submit' value='submit' />
<input type='Reset' value='reset' />
</form>
</body>
</html>
EXERCISE:
1. Create a rich graphical webpage using CSS (ID selector & Class Selectors).
b) factorial.html
<html>
<head>
<title>factorial</title>
<script language='javascript'>
EXERCISE:
1. Write a JavaScript program to find out the Fibonacci Series.
2. Write a JavaScript program to check the given number is palindrome or not.
OUTPUT:
Output:
if($t==$rev)
echo "$rev is a Palindrome";
else
echo "$rev is not a Palindrome";
?>
Output:
EXERCISE:
1. Write a PHP Script to find the factorial of a given number.
2. Write a PHP Script to find the fibonacci series of a given number.
EXERCISE:
1. Write a XML program to validate student details(Rno, Name, college & branch)
using DTD and Schemas.
2. Write a XML program to validate book details( Title of the book, Author Name,
ISBN no & Publication) using DTD and Schemas.
9 (i) (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).
PROGRAM:
login.html
<html>
<form action="home.php" method="post">
Username<input type="text" name="text1"><br>
<input type="submit" value="SignIn" name="submit">
</form>
</html>
Output of login.html:
Home.php:
<?php
session_start();
date_default_timezone_set("Asia/Calcutta");
$_SESSION['luser'] = $_POST['text1'];
$_SESSION['start'] = time();
$tm=$_SESSION['start'];
print "<p align='right'>Session started at " . date("h:i:sa",$tm) . "<br>";
print "<form action='logoutpage.php' method='post'>";
print "<input type='submit' value='Logout'></p>";
print "</form>";
print "Hello " . $_SESSION['luser'];
?>
Logoutpage.php:
<?php
session_start();
date_default_timezone_set("Asia/Calcutta");
print "<p align='right'>Session started at " . date("h:i:sa",time()) . "</p><br>";
print "Thank you " . $_SESSION['luser'];
$sessiontime = time() - $_SESSION['start'];
print "<br> Your session duration: " . $sessiontime . " seconds";
session_destroy();
?>
Output of Logoutpage.php:
Output:
Output:
USING SERVLET
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/html");
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();
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();
}
} }
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/html");
//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>
<servlet-name>Date</servlet-name>
<url-pattern>/date</url-pattern>
</servlet-mapping>
</web-app>
Output:
//Reading cookies
Cookie c[]=request.getCookies();
//Displaying User name and User Password value from cookie
for(int i=0;i<c.length;i++){
pwriter.print("<br>"+c[i].getName()+": "+c[i].getValue());//printing name and value of
cookie
}
pwriter.close();
}catch(Exception exp){
System.out.println(exp);
}
}
}
web.xml
<web-app>
<display-name>Cookies Example</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Servlet1</servlet-name>
<servlet-class>MyServlet1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet1</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Servlet2</servlet-name>
<servlet-class>MyServlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet2</servlet-name>
<url-pattern>/welcome</url-pattern>
</servlet-mapping>
</web-app>
Sessionjsp.html
<html>
<head> <title> SESSION LOGIN </title> </head>
<body>
<center>
<form action="http://localhost:8080/jsp/Session1.jsp" method="get">
Enter Name: <input type="text" name="uname"> <br>
<input type="submit" value="LOGIN" name="register">
</form>
</center>
</body>
</html>
Session1.jsp
<%@page language="java" import="java.util.*" errorPage=""%>
<form method="get" action="http://localhost:8080/jsp/Session2.jsp">
<%
Date d=new Date();
%>
<p align="right"> Time;<%=d.getTime()%></p>
<%
String un=request.getParameter("uname");
session.setAttribute("user",un);
session.setAttribute("time",d.getTime());
%>
Hello <%=un%>
<br><br>
<input type="submit" value="logout">
</form>
Session2.jsp
<%@page language="java" import="java.util.*" errorPage=""%>
<%
Date d2=new Date();
String un=(String)session.getAttribute("user");
Long t1=(Long)session.getAttribute("time");
Long t2=d2.getTime();
%>
Thank you <%=un%>
<br><br>
Session duration: <%=(t2-t1)/(60*60)%> seconds
<% session.invalidate();%>
cookie.html
<html>
<head> <title> Calculator </title> </head>
<body>
<form action="http://localhost:8080/jsp/cookie1.jsp" method="post">
Enter your name:<input type="text" name="name1" placeholder="Enter name">
<input type="submit" value="Add cookie">
</form>
</center>
</body>
</html>
cookie1.jsp
<%@page language="java" import="java.sql.*" errorPage=""%>
<%
String name=request.getParameter("name1");
Cookie c1=new Cookie ("firstname",name);
response.addCookie(c1);
c1.setMaxAge(50*50);
%>
<form method="get" action="http://localhost:8080/jsp/cookie2.jsp">
<input type="submit" value="List Cookies">
</form>
cookie2.jsp
<%@page language="java" import="java.sql.*" errorPage=""%>
<title> List of Cookies </title>
<h1> List of Cookies </h1>
<%
Cookie[] cookies=request.getCookies();
%>
<table border=1>
</tr>
<%
out.println("<td> Cookie Name </td> <td> Cookie value </td>");
for(int i=0;i<cookies.length;i++)
{
out.println("<h2> <tr> <td>
"+cookies[i].getName()+"</td><td>"+cookies[i].getValue()+"</td></tr>");
}
%>
</tr>
</table>
a) A user validation web application, where the user submits the login name & password
to the server. The name and password are checked against the data already available in
Database and if the data matches, a successful login page is returned. Otherwise failure
message is shown to the user.
AIM: To design an application that verifies user details from database using PHP.
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 connection
if (!$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')";
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>
<?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:
OUTPUT:
import java.sql.*;
class MysqlCon{
public static void main(String args[]){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/sonoo","root","root");
//here sonoo is database name, root is username and password
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from emp");
while(rs.next())
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));
con.close();
}catch(Exception e){ System.out.println(e);}
}
}
OUTPUT:
AIM: To design an application that verifies user details from an xml using PHP.
PROGRAM:
db.php
Userlogin.xml:
<Authentication>
<user>
<username>cse</username>
<password>5</password>
</user>
<user>
<username>mrcet</username>
<password>mlrd</password>
</user>
</Authentication>
Loginform.php:
<html>
<head>
<title> Registration page </title>
</head>
<body bgcolor="pink">
<?php
$myxml=simplexml_load_file("Userlogin.xml");
$username=$_POST['uname'];
$password=$_POST['upwd'];
$xmlusername="";
$xmlpassword="";
for($i=0;$i<count($myxml);$i++)
{
$xmlusername=$myxml->user[$i]->username;
$xmlpassword=$myxml->user[$i]->password;
if($xmlusername==$username && $xmlpassword==$password)
{
echo "welcome $username";
die();
}
}
echo "Invalid username or password";
?>
</body>
</html>
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:
2. What is CSS?
Answer: CSS (Cascading Style Sheets) is used to style and layout web pages, including
colors, fonts, and positioning.
3. What is JavaScript?
Answer: JavaScript is a programming language that adds interactivity and dynamic
behavior to web pages.
10. What is the difference between GET and POST methods in HTTP?
Answer:
GET requests data from a server and appends it to the URL.
POST sends data to a server securely in the request body.
17. What is the difference between inline and block elements in HTML?
Answer:
Inline elements (e.g., <span>) do not start on a new line.
Block elements (e.g., <div>) take up the full width and start on a new line.