WE LAB Full Manual 2025
WE LAB Full Manual 2025
Date:
Procedure:
• Save an image named "bike.jpg" in the same directory as your HTML file.
• Locate the file in your system and double-click it to open in a web browser.
Program:
<html>
<head>
<title>Interactive Webpage</title>
</head>
<body>
<h2>Interactive Webpage</h2>
It's a set of codes that tells web browsers how to display text and images on a web page. <br>
<br><br>
oninput="document.body.bgColor = this.value;">
<br><br>
</body>
</html>
Output:
Result:
Procedure:
1. Start
2. Create an HTML form with Name, Password fields, and a Submit button.
Program:
<!DOCTYPE html>
<html>
<head>
<title>Form Validation</title>
</head>
<body>
</form>
<script>
function validateForm()
return false;
return false;
var message = "Registration Successful!\n\n" +"Name: " + name + "\n" +"Password: " + password;
alert(message);
return false;
</script>
</body>
</html>
Output:
Result
Thus the above HTML code for form validation has been executed successfully.
Ex No : 3
Date:
Procedure:
5. Declare Variables:
6. Display Information:
8. Use Loop:
Save as .php and execute on a server. Type this URL in browser http://localhost/pgm3.php
Program:
<!DOCTYPE html>
<html>
<head>
<title>Personal Information</title>
</head>
<body>
<?php
$name = "Krish";
$age = 25;
?>
<h3>Personal Information</h3>
<?php
function display($name)
?>
<?php
?>
</body>
</html>
Output:
Result
Thus the above HTML code for form validation has been executed successfully.
Ex No : 4
Procedure:
Use the <iframe> tag with the src attribute pointing to a YouTube video.
Include a fallback message for browsers that don't support the video tag.
Program:
<!DOCTYPE html>
<html>
<head>
<title>Multimedia Content</title>
</head>
<body>
<h3>HTML Video Tag</h3>
<p>Adding an online video from YouTube:</p>
<iframe width="450" height="250"
src="https://www.youtube.com/embed/GUXZoWDztSE"
frameborder="0" allowfullscreen>
</iframe>
<h3>Internal Video Sample</h3>
<p>Playing a locally stored video:</p>
<video width="450" height="250" controls>
<source src="myvideo.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
<h3>Audio Sample</h3>
<audio controls>
<source src="test.mp3" type="audio/mp3">
Your browser does not support the audio element.
</audio>
</body>
</html>
Output:
Result
Thus the above HTML code for form validation has been executed successfully.
Ex No : 5a
Date:
Invoke Servlets from HTML Forms
Aim:
To Invoke Servlets from HTML Forms
Procedure:
1. Download & Install Eclipse (Eclipse IDE for Enterprise Java and Web Developers).
2. Install Apache Tomcat (Version 9 or higher recommended).
3. Configure Tomcat in Eclipse:
o Open Eclipse → Go to Window → Preferences.
o Navigate to Server → Runtime Environments.
o Click Add → Select Apache Tomcat version → Browse to your Tomcat installation
directory → Click Finish.
Html:
<!DOCTYPE html>
<html>
<head>
<title>Invoking Servlet From HTML</title>
</head>
<body bgcolor="AntiqueWhite">
<form name="form1" method="post" action="http://localhost:8080/ServletExample/server">
<fieldset>
<legend>Registration</legend>
First Name: <input type="text" name="FirstName" size="25"/><br/><br/>
Last Name: <input type="text" name="LastName" size="25"/><br/><br/>
E-mail ID: <input type="email" name="EmailID" size="25"/><br/><br/>
Password: <input type="password" name="Password" size="25"/><br/><br/>
<input type="submit" value="SUBMIT">
</fieldset>
</form>
</body>
</html>
Output:
Result
Thus the above program has been executed successfully.
Ex No : 5b
Date:
Session Tracking using Hidden Form Fields
Aim:
To create Session Tracking using Hidden Form Fields.
Procedure:
Program:
Xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<servlet>
<servlet-name>SetServlet2</servlet-name>
<servlet-class>com.example.SetServlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SetServlet2</servlet-name>
<url-pattern>/SetServlet2</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>GetServlet2</servlet-name>
<servlet-class>com.example.GetServlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>GetServlet2</servlet-name>
<url-pattern>/GetServlet2</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
</web-app>
Html:
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<meta charset="UTF-8">
</head>
<body>
<h2>Login Page</h2>
<form action="SetServlet2" method="post">
Username: <input type="text" name="userName" required><br><br>
Password: <input type="password" name="password" required><br><br>
<input type="submit" value="Login">
</form>
</body>
</html>
Java: SetServlet2
package com.example;
import java.io.IOException;
import java.io.PrintWriter;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
GetServlet2
package com.example;
import java.io.IOException;
import java.io.PrintWriter;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
out.println("<h2>Retrieved Values</h2>");
out.println("<p>Username: " + userName + "</p>");
out.println("<p>Password: " + password + "</p>");
out.close();
}
}
Output:
Result
Thus the above program has been executed successfully.
Ex No : 5c
Date:
Session Tracking for a Hit Count
Aim:
To create Session Tracking for a Hit Count.
Procedure:
Step 1: Create a New Dynamic Web Project
1. Open Eclipse.
2. Go to File → New → Dynamic Web Project.
3. Enter Project Name: SessionCount.
4. Select Target Runtime: Choose Apache Tomcat (already configured).
5. Click Finish.
Step 2: Configure web.xml
1. In Project Explorer, go to Webapp/WEB-INF/.
2. Right-click → New → File → Name it web.xml.
3. Type the xml code there.
4. Save the file.
Step 3: Create the Servlet
1. In Project Explorer, go to Java Resources/src.
2. Right-click → New → Servlet.
3. Enter Package Name: com.example
4. Enter Class Name: Session
5. Click Finish, then type java code there.
6. Save the file.
Step 5: Run the Project
1. Right-click on the project → Run As → Run on Server.
2. Choose Apache Tomcat → Click Finish.
3. Open a browser and visit:
http://localhost:8080/SessionCount/Session
4. Refresh the page multiple times to see the session count increase.
Program:
Xml:
<servlet>
<servlet-name>Session</servlet-name>
<servlet-class>com.example.Session</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Session</servlet-name>
<url-pattern>/Session</url-pattern>
</servlet-mapping>
</web-app>
Java:
package com.example;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
Output:
Result
Thus the above program has been executed successfully.
Ex No : 6
Date:
Creation of Information Retrieval System
Aim:
To create Information Retrieval System.
Procedure:
MYSQL :
<?php
$servername = "localhost:3307";
$username = "root";
$password = "";
$dbname = "test";
if (!empty($selectedName)) {
$sql = "SELECT * FROM stud WHERE Sname = '$selectedName'";
} else {
$sql = "SELECT * FROM stud";
}
$result = $conn->query($sql);
?>
<!DOCTYPE html>
<html>
<head>
<title>Student Data</title>
<style>
body {
background-color: #bbdefb;
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
h2 {
text-align: center;
color: #0d47a1;
margin-top: 20px;
}
form {
text-align: center;
margin-bottom: 20px;
}
select, input {
padding: 10px;
font-size: 16px;
margin: 5px;
}
table {
border-collapse: collapse;
width: 40%;
margin: 20px auto;
background-color: white;
box-shadow: 2px 2px 10px gray;
}
th, td {
border: 1px solid black;
padding: 8px;
font-size: 14px;
}
th {
background-color: #1565c0;
color: white;
}
</style>
</head>
<body>
<form method="post">
<label for="sname"><strong>Select Student:</strong></label>
<select name="sname">
<option value="">-- All Students --</option>
<?php
if ($studResult->num_rows > 0) {
while ($row = $studResult->fetch_assoc()) {
$selected = ($selectedName == $row['Sname']) ? "selected" : "";
echo "<option value='{$row['Sname']}' $selected>{$row['Sname']}</option>";
}
}
?>
</select>
<input type="submit" value="Search">
</form>
<table>
<thead>
<tr>
<th>Sno</th>
<th>Sname</th>
<th>Dept</th>
</tr>
</thead>
<tbody>
<?php
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<tr>
<td>{$row['Sno']}</td>
<td>{$row['Sname']}</td>
<td>{$row['Dept']}</td>
</tr>";
}
} else {
echo "<tr><td colspan='3'>No records found</td></tr>";
}
?>
</tbody>
</table>
</body>
</html>
<?php
$conn->close();
?>
Output:
Result
Thus the above program has been executed successfully.
Ex No : 7
Date:
Creation of Personal Information System
Aim:
To create Personal Information System
Procedure:
Step 1: Start Apache & MySQL
1. Open XAMPP Control Panel.
2. Start Apache and MySQL modules.
MYSQL :
CREATE TABLE emp (
Eno INT PRIMARY KEY,
Ename VARCHAR(50),
Sal INT,
City VARCHAR(50)
);
PHP Code:
<?php
$servername = "localhost:3307";
$username = "root";
$password = "";
$db = "test";
$conn = new mysqli($servername, $username, $password, $db);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Employee Information System</title>
<style>
body {
background: linear-gradient(to right, #8e24aa, #6a1b9a); /* darker purple gradient */
text-align: center;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 0;
}
h1 {
margin-top: 30px;
color: #f3e5f5;
text-shadow: 1px 1px 2px #000;
}
form {
display: inline-block;
text-align: left;
padding: 25px;
margin-top: 20px;
background-color: #ffffff;
border: 2px solid #ba68c8;
border-radius: 12px;
box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}
input[type="text"], input[type="number"] {
width: 300px;
padding: 10px;
margin: 10px 0;
border: 1px solid #ce93d8;
border-radius: 6px;
box-sizing: border-box;
font-size: 16px;
}
input[type="submit"] {
background-color: #ab47bc;
color: white;
padding: 10px 20px;
margin-top: 10px;
border: none;
border-radius: 20px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
}
input[type="submit"]:hover {
background-color: #7b1fa2;
}
table {
margin: 30px auto;
border-collapse: collapse;
width: 60%;
background-color: #fff;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}
th {
background-color: #ce93d8;
color: white;
padding: 10px;
font-size: 14px;
}
td {
padding: 8px;
border-bottom: 1px solid #ddd;
}
tr:nth-child(even) {
background-color: #f3e5f5;
}
h2 {
color: #f3e5f5;
margin-top: 40px;
}
</style>
</head>
<body>
<h1>Employee Information System</h1>
<form method="post">
<label>Employee No (Eno):</label><br>
<input type="number" name="eno" placeholder="Enter Eno" required><br>
<label>Employee Name (Ename):</label><br>
<input type="text" name="ename" placeholder="Enter Name" required><br>
<label>Salary:</label><br>
<input type="number" name="sal" placeholder="Enter Salary" required><br>
<label>City:</label><br>
<input type="text" name="city" placeholder="Enter City" required><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
if(isset($_POST['submit'])) {
$eno = $_POST['eno'];
$ename = $_POST['ename'];
$sal = $_POST['sal'];
$city = $_POST['city'];
$qry = "INSERT INTO emp (Eno, Ename, Sal, City)
VALUES ('$eno', '$ename', '$sal', '$city')";
if(mysqli_query($conn, $qry)) {
echo '<script>alert("Employee Registered Successfully");</script>';
echo '<script>window.location.href="test1.php";</script>';
} else {
echo "Error: " . mysqli_error($conn);
}
}
?>
<h2>Employee Details</h2>
<table>
<thead>
<tr>
<th>Eno</th>
<th>Ename</th>
<th>Salary</th>
<th>City</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM emp";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<tr>
<td>{$row['Eno']}</td>
<td>{$row['Ename']}</td>
<td>{$row['Sal']}</td>
<td>{$row['City']}</td>
</tr>";
}
} else {
echo "<tr><td colspan='4'>No records found</td></tr>";
}
?>
</tbody>
</table>
</body>
</html>
<?php
$conn->close();
?>
Output:
Result
Thus the above program has been executed successfully.