Saanp File
Saanp File
PRACTICAL FILE
Subject: Web Technology Lab
Subject Code: BCS-552
Course: B. Tech Branch: CSE Semester: 5th
Session Odd Sem 2024-25
INDEX
S. Name of Experiment Date Page Remarks Signature
No. No.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Institute Website</title>
<style>
body {
margin: 0;
padding: 0;
background-color: #f4f4f4;
overflow-x: hidden;
header {
color: white;
padding: 1rem 0;
text-align: center;
nav {
background-color: black;
padding: 0.6rem;
text-align: center;
}
4|Page
nav a {
color: white;
margin: 0 15px;
text-decoration: none;
.container {
padding: 2rem;
.department {
margin: 1rem 0;
padding: 1rem;
border-radius: 5px;
footer {
text-align: center;
padding: 0.6rem;
background-color: black;
color: white;
position: relative;
/* bottom: 0; */
width: 100%;
height: 40px;
/* align-items: center; */
</style>
</head>
5|Page
<body>
<header>
</header>
<nav>
<a href="#about">About</a>
<a href="#departments">Departments</a>
<a href="#contact">Contact</a>
</nav>
<div class="container">
<section id="about">
<h2>About Us</h2>
<p>Our institute is dedicated to providing high-quality education and fostering innovation and
creativity
among students.</p>
</section>
<section id="departments">
<h2>Departments</h2>
<div class="department">
</div>
<div class="department">
<h3>Department of Electronics</h3>
</div>
<div class="department">
</div>
<div class="department">
</div>
</section>
<section id="contact">
<h2>Contact Us</h2>
<p>Email: [email protected]</p>
<p>Phone: 0120-2322022</p>
</section>
</div>
<footer>
</footer>
</body>
</html>
7|Page
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body {
margin: 0;
padding: 0;
background-color: #e6f7ff;
.form-container {
max-width: 400px;
padding: 20px;
background: white;
border-radius: 8px;
h2 {
text-align: center;
color: #333;
width: 100%;
padding: 10px;
margin: 10px 0;
border-radius: 4px;
}
8|Page
button {
width: 100%;
padding: 10px;
background: #0073e6;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
button:hover {
background: #005bb5;
</style>
</head>
<body>
<div class="form-container">
<h2>Student Details</h2>
<form>
<label for="name">Name:</label>
<label for="email">Email:</label>
<label for="department">Department:</label>
<option>Computer Science</option>
<option>Electronics</option>
<option>Mechanical</option>
<option>Civil</option>
9|Page
<option>Electrical</option>
</select>
<button type="submit">Submit</button>
</form>
</div>
</body>
</html>
10 | P a g e
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
/* General Reset */
*{
margin: 0;
padding: 0;
box-sizing: border-box;
body {
color: #333;
a{
text-decoration: none;
color: inherit;
ul {
list-style: none;
/* Header */
.header {
11 | P a g e
background: #333;
color: white;
display: flex;
justify-content: space-between;
align-items: center;
.header .logo {
font-size: 24px;
font-weight: bold;
.header .navbar ul {
display: flex;
gap: 20px;
.header .navbar a {
color: white;
font-size: 16px;
/* Hero Section */
.hero {
display: flex;
justify-content: center;
align-items: center;
height: 60vh;
text-align: center;
color: white;
padding: 20px;
12 | P a g e
.hero h1 {
font-size: 48px;
margin-bottom: 10px;
color: #f3af03;
.hero p {
font-size: 20px;
margin-bottom: 20px;
color: blue;
.hero .cta {
background: #ff5733;
color: white;
border-radius: 5px;
/* Products Section */
.products {
.products h2 {
text-align: center;
margin-bottom: 20px;
font-size: 32px;
}
13 | P a g e
.products .product-grid {
display: grid;
gap: 20px;
.products .product-card {
border-radius: 8px;
overflow: hidden;
background: white;
.products .product-card:hover {
transform: translateY(-5px);
width: 100%;
height: auto;
padding: 15px;
text-align: center;
.products .product-card h3 {
margin-bottom: 10px;
font-size: 18px;
}
14 | P a g e
.products .product-card p {
color: #ff5733;
font-size: 16px;
margin-bottom: 15px;
background: #ff5733;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
/* About Section */
.about {
text-align: center;
background: #f9f9f9;
.about h2 {
margin-bottom: 20px;
font-size: 32px;
.about p {
max-width: 600px;
margin: 0 auto;
line-height: 1.6;
}
15 | P a g e
/* Contact Section */
.contact {
text-align: center;
.contact form {
max-width: 500px;
margin: 0 auto;
display: block;
margin-bottom: 5px;
font-weight: bold;
width: 100%;
padding: 10px;
margin-bottom: 15px;
border-radius: 5px;
background: #ff5733;
color: white;
border: none;
border-radius: 5px;
16 | P a g e
cursor: pointer;
/* Footer */
.footer {
background: #333;
color: white;
text-align: center;
padding: 10px;
/* Media Queries */
.hero h1 {
font-size: 32px;
.hero p {
font-size: 16px;
</style>
</head>
<body>
<header class="header">
<div class="logo">ShopEase</div>
<nav class="navbar">
<ul>
<li><a href="#products">Products</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
17 | P a g e
</ul>
</nav>
</header>
<section class="hero">
<div>
<h1>Welcome to ShopEase</h1>
</div>
</section>
<h2>Our Products</h2>
<div class="product-grid">
<div class="product-card">
<div class="details">
<h3>Product 1</h3>
<p>$19.99</p>
<button>Add to Cart</button>
</div>
</div>
<div class="product-card">
<div class="details">
<h3>Product 2</h3>
<p>$29.99</p>
<button>Add to Cart</button>
</div>
</div>
18 | P a g e
<div class="product-card">
<div class="details">
<h3>Product 3</h3>
<p>$39.99</p>
<button>Add to Cart</button>
</div>
</div>
<div class="product-card">
<div class="details">
<h3>Product 4</h3>
<p>$49.99</p>
<button>Add to Cart</button>
</div>
</div>
</div>
</section>
<h2>About Us</h2>
<p>We are dedicated to bringing you the best products at unbeatable prices. ShopEase is committed to
quality and
customer satisfaction.</p>
</section>
<h2>Contact Us</h2>
<form>
<label for="name">Name:</label>
<label for="email">Email:</label>
<label for="message">Message:</label>
<button type="submit">Send</button>
</form>
</section>
<footer class="footer">
</footer>
</body>
</html>
20 | P a g e
21 | P a g e
4. Write programs using HTML and Java Script for validation of input
data.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Form Validation</title>
<style>
body {
background-color: #f4f4f9;
margin: 0;
padding: 0;
.form-container {
max-width: 400px;
padding: 20px;
background: white;
border-radius: 8px;
input {
width: 100%;
padding: 10px;
margin: 10px 0;
border-radius: 4px;
button {
width: 100%;
padding: 10px;
22 | P a g e
background: #0073e6;
color: white;
border: none;
border-radius: 4px;
</style>
</head>
<body>
<div class="form-container">
<h2>Register</h2>
<form id="form">
</form>
</div>
<script>
function validateForm() {
return;
if (password.length < 6) {
return;
}
23 | P a g e
</script>
</body>
</html>
24 | P a g e
<!DOCTYPE html>
<html>
<head>
<style>
a{
text-decoration: none;
color: crimson;
font-weight: 900;
button {
border-radius: 8px;
background-color: burlywood;
font-weight: 700;
p{
font-weight: 900;
</style>
</head>
<body>
<script>
if ("geolocation" in navigator) {
document.getElementById("location").innerText = locationText;
document.getElementById("map-link").href = mapLink;
});
} else {
document.getElementById("location").innerText =
</script>
</body>
</html>
26 | P a g e
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Employee Data</title>
<style>
table {
width: 50%;
border-collapse: collapse;
th, td {
padding: 10px;
text-align: center;
th {
background-color: #f2f2f2;
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>Employee ID</th>
<th>Name</th>
<th>Salary</th>
27 | P a g e
<th>Department</th>
</tr>
</thead>
<tbody id="employeeTable">
</tbody>
</table>
<script>
fetch('http://localhost:3000/employees')
.then(data => {
data.forEach(employee => {
row.innerHTML = `
<td>${employee.employee_id}</td>
<td>${employee.name}</td>
<td>${employee.salary}</td>
<td>${employee.department}</td>
`;
tableBody.appendChild(row);
});
})
</script>
</body>
</html>
JAVASCRIPT FILE:
.then(client => {
console.log('Connected to Database');
const db = client.db(dbName);
app.use(express.static(path.join(__dirname, 'public')));
employeeCollection.find().toArray()
.then(employees => {
res.json(employees);
})
});
app.listen(3000, () => {
});
})
7.Using JavaScript display the content of XML file on webpage using HTML
and CSS.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body {
margin: 20px;
background-color: #f9f9f9;
.xml-container {
padding: 15px;
background: #fff;
.xml-item {
margin-bottom: 10px;
padding: 10px;
.xml-item:last-child {
border-bottom: none;
.xml-tag {
font-weight: bold;
color: #333;
}
31 | P a g e
</style>
</head>
<body>
<script>
document.addEventListener("DOMContentLoaded", () => {
const xmlData = `
<employees>
<employee>
<id>1</id>
<name>Aditya Verma</name>
<department>HR</department>
<salary>50000</salary>
</employee>
<employee>
<id>2</id>
<name>Harsh kumar</name>
<department>Finance</department>
<salary>60000</salary>
</employee>
<employee>
<id>3</id>
<name>Dev Bhargav</name>
<department>Marketing</department>
<salary>45000</salary>
</employee>
</employees>
`;
32 | P a g e
if (parseError.length) {
return;
Array.from(employees).forEach((employee) => {
const id = employee.getElementsByTagName("id")[0].textContent;
employeeDiv.className = "xml-item";
employeeDiv.innerHTML = `
`;
outputDiv.appendChild(employeeDiv);
});
});
33 | P a g e
</script>
</body>
</html>
34 | P a g e
USE user_registration;
name VARCHAR(100),
email VARCHAR(100),
password VARCHAR(100),
age INT
);
register.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>User Registration</title>
</head>
<body>
<h2>Register User</h2>
<label for="name">Name:</label><br>
<label for="email">Email:</label><br>
<label for="password">Password:</label><br>
<label for="age">Age:</label><br>
</form>
</body>
</html>
RegisterServlet.java:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
try {
36 | P a g e
Class.forName("com.mysql.cj.jdbc.Driver");
String sql = "INSERT INTO users (name, email, password, age) VALUES (?, ?, ?, ?)";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, name);
preparedStatement.setString(2, email);
preparedStatement.setString(3, password);
preparedStatement.setInt(4, age);
if (result > 0) {
} else {
response.getWriter().println("Error in registration!");
} catch (Exception e) {
e.printStackTrace();
} finally {
// Close resources
try {
} catch (SQLException e) {
37 | P a g e
e.printStackTrace();
web.xml:
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-
app_4_0.xsd"
version="4.0">
<servlet>
<servlet-name>RegisterServlet</servlet-name>
<servlet-class>RegisterServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RegisterServlet</servlet-name>
<url-pattern>/RegisterServlet</url-pattern>
</servlet-mapping>
</web-app>