Web essential lab manaul
Web essential lab manaul
Name : ………………………………………………….
Semester : ………………………………………………….
This is to Certify that the Bonafide record of the practical work done by
…………………………………. Register Number : …………………………………. of IInd
year B.TECH ( INFORMATION TECHNOLOGY ) submitted for the B.TECH IT practical
examination (IV th Semester) in IT3401 – WEB ESSENTIALS LABORATORY during the
academic year 2024 – 2025.
Ex Page Staff
Date Experiments
No. No. Signature
Aim:
To create the interactive web sites design using HTML and authoring tools.
Procedure:
1. Turn on the web server with necessary featured packages.
2. Confirm the running of the web server’s control page by using local host url.
3. Start your website construction from webserver’s localhost location.
4. Build the required html structure to deploy the appropriate web site.
5. Prepare and build the appropriate collection of required html pages.
6. Layout the web pages with relevant textual contents.
7. Style the html pages with Inline, Internal and External CSS Properties.
8. Format the html pages with required images with relevant options.
9. Prepare the html pages with anchor links to navigate with neighbouring pages.
10. Launch the website in the recommended web browser.
Program:
External CSS (mystyle.css)
body {
font-family: Arial, sans-serif;
}
h1 {
text-align: center;
color: navy;
}
h2 {
background-color: lightblue;
color: navy;
margin-left: 20px;
text-align: center;
text-decoration: underline;
}
/* Navigation Menu */
li {
display: inline;
padding: 18px;
color: white;
}
li:hover {
background-color: yellow;
color: black;
}
div {
background-color: brown;
padding: 2px;
border: none;
}
a {
text-decoration: none;
}
p {
font-size: 15px;
text-align: justify;
}
Webpage (webpage.html)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Welcome to IT Department</title>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<div>
<!-- Navigation Menu -->
<ul style="list-style-type: none;">
<li><a href="#">Home</a></li>
<li><a href="Department.html">Department</a></li>
<li><a href="Examination.html">Examination</a></li>
<li><a href="Admission.html">Admission</a></li>
<li><a href="Faculties.html">Faculties</a></li>
<li><a href="Facilities.html">Facilities</a></li>
<li><a href="About_Us.html">About Us</a></li>
<li><a href="Contact_Us.html">Contact Us</a></li>
</ul>
</div>
<p>
Sri Balaji Chockalingam Engineering College, an institution of
academic excellence, was established in the year 1999,
with a cherished desire to serve the cause of humanity through
technical higher education. This college has been affiliated
with Anna University, Chennai, and has been recognized by the
Government of Tamil Nadu. It is a Co-Educational Engineering
College offering six B.E./B.Tech. courses and four P.G. courses.
All the courses have been recognized by the All India
Council for Technical Education, New Delhi, and accredited by
NBA.
</p>
</body>
</html>
<p>
The Department of Information Technology was established in the
year 1999.
The motto of our department is to enhance the development and
competitive potential
of students to meet the current trends of the IT field in
society.
</p>
<p>
Our department has an expert team of well-qualified and
professionally experienced academic members.
They dedicate their intellectual approaches to emerging
technologies and direct students towards technological
and industrial activities through advisory layouts.
</p>
<p>
They are actively engaged in research and development activities
on recent and trending technologies.
The students are well equipped to face challenges in their
careers and adapt to future scenarios in IT sectors.
</p>
</body>
</html>
Note : Similarly create additional html pages for Examination, Admission, Faculties,
Facilities, About_Us, Contact_Us Pages.
OUTPUT :
Result:
The Creation of interactive web sites design using HTML and authoring tools has
been completed successfully.
EX NO : 2
DATE : Form Validation using JavaScript
Aim:
To validate the html forms at client side using Javascript.
Procedure:
1. Turn on the web server with necessary featured packages.
2. Confirm the running of the web server’s control page by using local host url.
3. Start your website construction from webserver’s localhost location.
4. Build the required html structure to deploy the appropriate web site.
5. Prepare and build the appropriate collection of required html pages.
6. Layout the web pages with relevant validating criteria and textual contents.
7. Style the html pages with Inline, Internal and External CSS Properties.
8. Format the html pages with required images with relevant options.
9. Prepare the html pages with anchor links to navigate with neighbouring pages.
10. Launch the website in the recommended web browser.
Program:
Webpage for Validation.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Validation</title>
<style>
body {
background-color: lightblue;
h1 {
color: navy;
margin-left: 20px;
text-align: center;
}
h2 {
color: navy;
margin-left: 20px;
text-align: center;
text-decoration: underline;
li {
display: inline;
padding: 18px;
color: white;
li:hover {
background-color: yellow;
color: black;
div#incss {
background-color: brown;
padding: 2px;
border: none;
a{
text-decoration: none;
p{
font-size: 15px;
text-align: justify;
width: 30%;
padding: 10px;
border-radius: 4px;
box-sizing: border-box;
resize: vertical;
label {
display: inline-block;
input[type=submit] {
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
.container {
border-radius: 5px;
background-color: #b4b4b4;
padding: 20px;
.col-25 {
float: left;
width: 15%;
margin-top: 6px;
background-color: #b4b4b4;
.col-75 {
float: left;
width: 75%;
margin-top: 6px;
background-color: #b4b4b4;
.row:after {
content: "";
display: table;
clear: both;
background-color: #b4b4b4;
</style>
</head>
<body>
<div id="incss">
<ul style="list-style-type:none;">
<a href="#"><li>Home</li></a>
<a href="#"><li>Department</li></a>
<a href="#"><li>Examination</li></a>
<a href="#"><li>Admission</li></a>
<a href="#"><li>Faculties</li></a>
<a href="#"><li>Facilities</li></a>
</ul>
</div>
<div class="container">
<div class="row">
<div class="col-25">
</div>
<div class="col-75">
<input type="text" id="regno" name="regno" onchange="isregno()" placeholder="Your register
number...">
</div>
</div>
<div class="row">
<div class="col-25">
</div>
<div class="col-75">
</div>
</div>
<div class="row">
<div class="col-25">
</div>
<div class="col-75">
</div>
</div>
<div class="row">
<div class="col-25">
</div>
<div class="col-75">
</div>
</div>
<div class="row">
<div class="col-25">
</div>
<div class="col-75">
</div>
</div>
</div>
</form>
</div>
<script type="text/javascript">
function validate_form() {
valid = false;
} else {
alert(result);
form.regno.value = "";
form.studname.value = "";
form.dob.value = "";
form.mothername.value = "";
form.fathername.value = "";
valid = false;
return valid;
function isregno() {
let rn = document.myform.regno;
if (isNaN(rn.value)) {
rn.focus();
rn.select();
function issntxts() {
let sn = document.myform.studname;
if (!isNaN(sn.value)) {
sn.focus();
sn.select();
function issntxtm() {
let mn = document.myform.mothername;
if (!isNaN(mn.value)) {
mn.focus();
mn.select();
function issntxtf() {
let fn = document.myform.fathername;
if (!isNaN(fn.value)) {
fn.focus();
fn.select();
</script>
</body>
</html>
OUTPUT :
Result:
The validation of html forms at client side using HTML and authoring tools has
been completed successfully.
EX NO : 3
DATE : Creation of simple PHP scripts
Aim:
To create the simple PHP scripts using PHP Interpreters.
Procedure:
1. Turn on the web server with necessary featured packages.
2. Confirm the running of the web server’s control page by using local host url.
3. Start your website construction from webserver’s localhost location.
4. Build the required html structure to deploy the appropriate web site.
5. Prepare and build the appropriate collection of PHP scripts.
6. Layout the web pages with relevant PHP code contents.
7. Format the html pages with required images with relevant options.
8. Run the required output in the recommended web browser.
Program:
Here is your properly formatted and structured PHP code:
<!DOCTYPE html>
<html>
<body>
<?php
// Creating Different Variables
$txt = "Hello world!";
$x = 5;
$y = 10.5;
echo $txt;
echo "<br>";
echo $x;
echo "<br>";
echo $y;
?>
</body>
</html>
Output:
Hello world!
5
10.5
Test Global Scope (Variable Outside Function)
<!DOCTYPE html>
<html>
<body>
<?php
$x = 5; // Global scope
function myTest() {
// Using $x inside this function will generate an error
echo "<p>Variable x inside function is: $x</p>";
}
myTest();
echo "<p>Variable x outside function is: $x</p>";
?>
</body>
</html>
Output:
Variable x inside function is:
Variable x outside function is: 5
<?php
function myTest() {
$x = 5; // Local scope
echo "<p>Variable x inside function is: $x</p>";
}
myTest();
</body>
</html>
Output:
Variable x inside function is: 5
Variable x outside function is: (Error, since $x is not defined
outside)
Using Global Keyword to Access a Global Variable Within a Function
<!DOCTYPE html>
<html>
<body>
<?php
$x = 5;
$y = 10;
function myTest() {
global $x, $y;
$y = $x + $y;
}
</body>
</html>
Output:
The value obtained by accessing the variables using Global keyword
is: 15
Result:
The Creation of simple php scripts using php interpreters has been completed
successfully.
EX NO : 4
Date : Handling multimedia content in web sites
What is Multimedia?
Multimedia comes in many different formats. It can be almost anything you can hear or see, like
images, music, sound, videos, records, films, animations, and more. Web pages often contain
multimedia elements of different types and formats. Multimedia on the web is sound, music, videos,
movies, and animations.
Multimedia Formats
Multimedia elements (like audio or video) are stored in media files. The most common way to
discover the type of a file, is to look at the file extension. Multimedia files have formats and different
extensions like: .wav, .mp3, .mp4, .mpg, .wmv, and .avi.
The MP4, WebM, and Ogg formats are only supported by HTML. The controls attribute adds video
controls, like play, pause, and volume. It is a good idea to always include width and height attributes. If
height and width are not set, the page might flicker while the video loads. The <source> element allows you
to specify alternative video files which the browser may choose from. The browser will use the first
recognized format.
Format File Description
.mpg MPEG. Developed by the Moving Pictures Expert Group. The first
MPEG
.mpeg popular video format on the web. Not supported anymore in HTML.
.rm RealVideo. Developed by Real Media to allow video streaming with low
RealVideo
.ram bandwidths. Does not play in web browsers.
MP3 files are actually the sound part of MPEG files. MP3 is the most
MP3 .mp3 popular format for music players. Combines good compression (small
files) with high quality. Supported by all browsers.
MP4 is a video format, but can also be used for audio. Supported by all
MP4 .mp4
browsers.
Programs :
HTML Video
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Video Controls</title>
<style>
body {
font-family: Arial, sans-serif;
}
.video-container {
text-align: center;
margin-top: 20px;
}
button {
padding: 10px 15px;
margin: 5px;
font-size: 16px;
cursor: pointer;
border: none;
background-color: #4CAF50;
color: white;
border-radius: 5px;
}
button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="video-container">
<button onclick="playPause()">Play/Pause</button>
<button onclick="makeBig()">Big</button>
<button onclick="makeSmall()">Small</button>
<button onclick="makeNormal()">Normal</button>
<br><br>
<video id="video1" width="420" controls autoplay muted>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
</div>
<script>
var myVideo = document.getElementById("video1");
function playPause() {
if (myVideo.paused) {
myVideo.play();
} else {
myVideo.pause();
}
}
function makeBig() {
myVideo.width = 560;
}
function makeSmall() {
myVideo.width = 320;
}
function makeNormal() {
myVideo.width = 420;
}
</script>
</body>
</html>
Output :
HTML Audio
<!DOCTYPE html>
<html>
<body>
<audio controls autoplay muted>
<source src=" file:///C:/Users/PROFESSOR%20SELVAM/Downloads/horse.ogg"
type="audio/ogg">
<source src=" file:///C:/Users/PROFESSOR%20SELVAM/Downloads/horse.mp3"
type="audio/mpeg">
</audio>
</body>
</html>
Output :
Result :
The Handling multimedia content in web sites using html multimedia tags has been executed
successfully.
EX NO : 5A
Date :
INVOKING SERVLETS FROM HTML FORM
AIM:
To write a java program to invoke servlets from HTML form.
ALGORITHM:
At Client Side
1. Create a web page with file name “Client.html” using HTML form that contains First Name, Last
Name, Email ID and Password fields by using input types such as text, password and submit button.
2. Set the URL of the server as the value of form’s action attribute.
3. Run the HTML program.
4. Submit the form data to the server.
At Server Side
General Settings:
1. Install Java with latest version and check the version of the java installation by using the following
command in command prompt : “java --version”, it will shows as follows as,
java version "20" 2023-03-21
Java(TM) SE Runtime Environment (build 20+36-2344)
Java HotSpot(TM) 64-Bit Server VM (build 20+36-2344, mixed mode, sharing)
(1) Define the class server that extends the property of the class GenericServlet.
(2) Handle the request from the client by using the method service() of GenericServlet class.
(3) Get the parameter names from the HTML form by using the method getParameterNames().
(4) Get the parameter values from the HTML forms by using the method getParameter().
(5) Send the response to the client by using the method of PrintWriter class.
server.java:
import java.io.*;
import
java.util.*;
import jakarta.servlet.*;
public class server extends GenericServlet
{
public void service(ServletRequest req,ServletResponse res)throws
ServletException,IOException
{
// Set response content type
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
pw.println("<body style='background-
color:AntiqueWhite;'>"); pw.println("<h1 style='text-
align:center;'>"+"Registration
Successful..."+"</h1>");
Enumeration e=req.getParameterNames();
while(e.hasMoreElements())
{
String str1=(String)e.nextElement();
String str2=req.getParameter(str1);
pw.println("<h2 style='text-align:center;'>"+str1+"= "+str2+"</h2>");
}
pw.println("</body>");
pw.close();
}
}
web.xml:
<web-app>
<servlet>
<servlet-name>Register</servlet-name>
<servlet-class>server</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Register</servlet-name>
<url-pattern>/server</url-pattern>
</servlet-mapping>
</web-app>
Client.html:
<html>
<head>
<title>Invoking Servlet From HTML</title>
</head>
<body bgcolor="AntiqueWhite">
<form name="form1" method="post"
action="http://localhost:8080/examples/server">
<fieldset>
<legend>Registration</legend>
First Name :
<input type="text" name="First Name " size="25"/><br/><br/>
Last Name :
<input type="text" name="Last Name " size="25"/><br/><br/>
E-mail ID :
<input type="text" name="LoginID " size="25"/><br/><br/>
Password :
<input type="password" name="Password " size="25">
<input type="submit" Value="SUBMIT">
</fieldset>
</form>
</body>
</html>
Output:
Result :
The java servlet were invoked from HTML form using java program has been successfully
completed.
EX NO : 5B
DATE : Session tracking using hidden form fields
Aim:
To perform session tracking using hidden form field.
Procedure:
1. Import the required header files.
2. Create SessionTracker as derived for the base class HttpServlet.
3. Define the doGet method with required HttpServletRequest
and HttpServletResponse variables.
4. Set the content type of the response as “text/html”.
5. Get the content of the response variable by getWrite() method.
6. Assign the content of the response variable for the PrintWriter class variable.
7. Get the content of the request variable by getSession() method.
8. Assign the content of the request variable for the HttpSession class variable.
9. Declare the required codes for Increment the hit count for this page.
10. The incremented value is saved in this client's session under the
name "tracker.count".
11. Develop the required Dhtml Response using appropriate output variables.
Program:
SetHiddenFieldServlet.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public SetHiddenFieldServlet() {
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
}
else if(userName.equals("sho") && password.equals("1234"))
{ out.println("Logged in successfully.<br/>"); out.println("Click
on the below button to see " +
"the values of Username and Password.<br/>");
out.print("<form action='GetHiddenFieldServlet'" +
" method='POST'>");
out.print("<input type='hidden' name='userName'" + "
value='" + userName + "'>");
out.print("<input type='hidden' name='password'" + "
value='" + password + "'>");
out.close();
}else{
out.print("Wrong username or password. <br/><br/>");
RequestDispatcher requestDispatcher =
request.getRequestDispatcher("/login.html");
requestDispatcher.include(request, response);
}
}
}
GetHiddenFieldServlet.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public GetHiddenFieldServlet() {
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html"); PrintWriter
out = response.getWriter();
out.close();
}
}
login.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
<br/><br/>
</form>
</body>
</html>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<servlet-class>
com.w3spoint.business.SetHiddenFieldServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SetHiddenFieldServlet</servlet-name>
<url-pattern>/SetHiddenFieldServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>GetHiddenFieldServlet</servlet-name>
<servlet-class>
com.w3spoint.business.GetHiddenFieldServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>GetHiddenFieldServlet</servlet-name>
<url-pattern>/GetHiddenFieldServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
</web-app>
Output:
Result:
The tracking of sessions using hidden form field has been completed successfully.
EX NO : 5C
DATE : Session Tracking for a Hit Count
Aim:
To perform session tracking for a hit count by viewing the web pages.
Procedure:
1. Import the required header files.
2. Create SessionTracker as derived for the base class HttpServlet.
3. Define the doGet method with required HttpServletRequest
and HttpServletResponse variables.
4. Set the content type of the response as “text/html”.
5. Get the content of the response variable by getWrite() method.
6. Assign the content of the response variable for the PrintWriter class variable.
7. Get the content of the request variable by getSession() method.
8. Assign the content of the request variable for the HttpSession class variable.
9. Declare the required codes for Increment the hit count for this page.
10. The incremented value is saved in this client's session under the
name "tracker.count".
11. Develop the required Dhtml Response using appropriate output variables.
Program:
SessionTracker.java
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionTracker extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
// Get the current session object, create one if necessary
HttpSession session = req.getSession();
// Increment the hit count for this page. The value is saved
// in this client's session under the name "tracker.count".
Output:
Result:
The tracking of sessions for hit count by viewing web pages for more than one time
has been completed successfully.
EX NO : 6
DATE : Creation of Information Retrieval System
Aim:
To create the information retrieval system using web, PHP and MySQL.
Procedure:
1. Create a required database appropriate table structure.
2. Structure the table with required attributes as fields.
3. Create a php structure for database connection with required variables.
4. Check the connection with server name, user name, password, database name.
5. Create an html structure with the title of Information Retrieval System.
6. Create an html form with required form input elements.
7. Format the form input elements with appropriate attributes.
8. Use POST method to submit the form data into the database.
9. Create a submit button at end of the form.
10. Write required PHP lines to retrieve information from the corresponding
table structure.
Program:
usersearch.html
<html>
<head>
<title>Information Retrieval System</title>
</head>
<body style="background-color : pink;">
<center>
<h1>Information Retrieval System</h1>
<form action="http://localhost/irs/phpSearchOption.php" method="post">
<label>Search By:</label>
<select name="column">
<option value="name">Name</option>
<option value="dob">Date of Birth</option>
<option value="mobno">Mobile No</option>
<option value="email">E-Mail</option>
<option value="address">Address</option>
</select>
<br>
<br>
<br>
<br>
</body>
</html>
phpsearchoption.php
<?php
$search = $_POST['search'];
$column = $_POST['column'];
$servername = "localhost";
$username = "root";
$password = "";
$db = "usertest";
$conn = new mysqli($servername, $username, $password, $db); if
($conn->connect_error){
die("Connection failed: ". $conn->connect_error);
}
$sql = "select * from userinfotable where $column like '%$search%'";
$result = $conn->query($sql);
if ($result->num_rows > 0){
while($row = $result->fetch_assoc() ){
echo"<head>";
echo"</body>";
echo"</html>";
}
} else {
echo"<head>";
echo"<title>Information Retrieval System</title>";
echo"</head>";
echo"<body style='background-color : pink;'>";
echo"<center>";
echo"<h1>Information Retrieval System</h1>";
echo"<h4>Retrived Information : </h4>";
}
$conn->close();
?>
Output:
Result:
The creation of information retrieval system using web, PHP and MySQL has been completed
successfully.
EX NO : 7
DATE : Creation of Personal Information System
Aim:
To create the personal information system using PHP and MySQL.
Procedure:
1. Create a required database appropriate table structure.
2. Structure the table with required attributes as fields.
3. Create a php structure for database connection with required variables.
4. Check the connection with server name, user name, password, database name.
5. Create an html structure with the title of Personal Information System.
6. Create an html form with required form input elements.
7. Format the form input elements with appropriate attributes.
8. Use POST method to submit the form data into the database.
9. Create a submit button at end of the form.
10. Write required PHP lines to get from the form elements and store into
the corresponding table structure.
Program:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$db="usertest";
// Create connection
$conn = new mysqli($servername, $username, $password,$db);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//echo "Connected successfully";
?>
<html>
<head>
<title> Personal Information System </title>
</head>
<body style="background-color : pink;">
<h1>Personal Information System</h1>
<form method="post">
<label>Name :</label>
<input type="text" name="name" placeholder="Enter Name">
<br><br>
<label>Date of Birth:</label>
<input type="text" name="dob" placeholder="Enter Date of Birth">
<br><br>
<label>E-mail: </label>
<input type="text" name="email" placeholder="Enter Email">
<br><br>
<label>Address: </label>
<input type="text" name="address" placeholder="Enter Address">
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$name=$_POST['name'];
$dob=$_POST['dob'];
$mobno=$_POST['mobno'];
$email=$_POST['email'];
$address=$_POST['address'];$qry="insert into userinfotable values(null,'$name',
'$dob','$mobno','$email','$address')"; if(mysqli_query($conn, $qry)){
echo'<script>alert("User Registerd Successfully");</script>';
header('location:test.php');
}
else
{
echo mysqli_error($conn);
}
}
?>
Output:
Result:
The creation of personal information system using PHP and MySQL has been
completed successfully.