Institute Website HTML Design Guide
Institute Website HTML Design Guide
Objective: Write an HTML program for designing your institute website. Display departmental
information of your institute on the website.
Apparatus/Tools Used:
Hardware Requirement: - Intel Core i5 8GB RAM, 256 GB SSD, Integrated Graphics Card,
1920 X 1080 Display.
● Inline CSS: Styles are directly applied using the style attribute within the HTML tags.
● Header: Displays the name of the institute in a large, bold format.
● Navigation: A simple horizontal navigation bar with links (not functional in this
example).
● Department Section: Each department has a title and a brief description.
● Footer: Contains copyright information.
Method / Procedure:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Institute - Departmental Information</title>
</head>
<body>
<h5>Courses Offered:</h5>
<ul>
<li>Bachelor of Science in Computer Science (BSc CS)</li>
<li>Master of Science in Computer Science (MSc CS)</li>
<li>Diploma in Software Engineering</li>
</ul>
<blockquote>
<p>"Innovating the future with technology." - Head of Department</p>
</blockquote>
</section>
<hr>
<h5>Courses Offered:</h5>
<ol>
<li>Bachelor of Technology in Mechanical Engineering (BTech ME)</li>
<li>Master of Technology in Mechanical Engineering (MTech ME)</li>
<li>Diploma in Automotive Engineering</li>
</ol>
<figure>
<img src="[Link]" alt="Mechanical Engineering Lab">
<figcaption>Mechanical Engineering Lab at ABC Institute</figcaption>
</figure>
</section>
<hr>
<h5>Courses Offered:</h5>
<ul>
<li>Bachelor of Technology in Electrical Engineering (BTech EE)</li>
<li>Master of Technology in Electrical Engineering (MTech EE)</li>
<li>Diploma in Power Systems</li>
</ul>
<table border="1">
<caption>Program Details</caption>
<thead>
<tr>
<th>Program Name</th>
<th>Duration</th>
<th>Eligibility</th>
</tr>
</thead>
<tbody>
<tr>
<td>BTech EE</td>
<td>4 Years</td>
<td>12th with Science</td>
</tr>
<tr>
<td>MTech EE</td>
<td>2 Years</td>
<td>BTech in Electrical Engineering</td>
</tr>
</tbody>
</table>
</section>
<hr>
<h5>Courses Offered:</h5>
<ul>
<li>Bachelor of Technology in Civil Engineering (BTech CE)</li>
<li>Master of Technology in Structural Engineering (MTech SE)</li>
<li>Diploma in Construction Technology</li>
</ul>
<details>
<summary>More Information about Civil Engineering</summary>
<p>Civil Engineering is one of the oldest and most important branches of engineering.
It involves the development of roads, bridges, buildings, and other infrastructure projects that
form the foundation of modern society.</p>
</details>
</section>
</section>
</body>
</html>
Input: Source code in terms of HTML and CSS files
Objective: Write an HTML program to design an entry form for student details/employee
information/faculty details.
Apparatus Used: -
Hardware Requirement: - Intel Core i5 8GB RAM, 256 GB SSD, Integrated Graphics Card,
1920 X 1080 Display.
Theory:
● Full Name: Text input for entering the person's full name.
● Email: Email input field with validation.
● Contact Number: Telephone number input.
● Role Selection: Dropdown menu to select the role (Student, Employee, Faculty).
● Address: Textarea for entering the address.
● Submit Button: A large, cantered submit button.
Method / Procedure:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Details Entry Form</title>
</head>
<body>
Objective: Develop a responsive website using CSS and HTML. Website may be for
tutorial/blogs/commercial website.
Apparatus/Tools Used:
Hardware Requirement: - Intel Core i5 8GB RAM, 256 GB SSD, Integrated Graphics Card,
1920 X 1080 Display.
<style>
body {
margin: 0;
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
/* Navigation Bar */
nav {
background-color: #003366;
color: white;
padding: 15px;
display: flex;
justify-content: space-between;
align-items: center;
}
nav .logo {
font-size: 22px;
font-weight: bold;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
}
nav ul li {
margin: 0 15px;
}
nav ul li a {
text-decoration: none;
color: white;
font-weight: bold;
}
/* Hero Section */
.hero {
background: url('[Link] no-repeat center/cover;
height: 350px;
display: flex;
justify-content: center;
align-items: center;
color: white;
text-align: center;
}
.hero h1 {
font-size: 45px;
background-color: rgba(0, 0, 0, 0.5);
padding: 10px 20px;
}
/* Cards Section */
.container {
padding: 30px;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.card {
background-color: white;
width: 30%;
padding: 20px;
box-shadow: 0 0 10px #aaa;
margin-bottom: 20px;
border-radius: 10px;
}
.card h3 {
color: #003366;
}
.card p {
color: #444;
}
/* Footer */
footer {
background-color: #003366;
color: white;
text-align: center;
padding: 15px;
margin-top: 20px;
}
/* RESPONSIVE DESIGN */
@media (max-width: 900px) {
.card {
width: 45%;
}
}
@media (max-width: 600px) {
nav ul {
flex-direction: column;
text-align: center;
}
nav ul li {
margin: 10px 0;
}
.card {
width: 100%;
} .hero h1 {
font-size: 30px;
}
}
</style>
</head>
<body>
<!-- Navigation -->
<nav>
<div class="logo">My Responsive Website</div>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Tutorials</a></li>
<li><a href="#">Blogs</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<section class="hero">
<h1>Welcome to My Tutorial & Blog Website</h1>
</section>
<!-- Cards Section -->
<div class="container">
<div class="card">
<h3>Web Development</h3>
<p>Learn HTML, CSS, JavaScript, and full-stack development tutorials.</p>
</div>
<div class="card">
<h3>Tech Blogs</h3>
<p>Read articles about latest technologies, gadgets, and innovations.</p>
</div>
<div class="card">
<h3>Commercial Services</h3>
<p>We provide website design, digital marketing, and SEO services.</p>
</div>
</div>
<!-- Footer -->
<footer>
© 2025 My Responsive Website | Designed with HTML & CSS
</footer>
</body>
</html>
Experiment No: 4
Objective: Write programs using HTML and JavaScript for validation of input data.
Apparatus/Tools Used:
Hardware Requirement: - Intel Core i5 8GB RAM, 256 GB SSD, Integrated Graphics Card,
1920 X 1080 Display.
● Header: Contains the title and a brief tagline for the website.
● Navigation Bar: A responsive menu that adjusts to screen sizes. Links highlight when
hovered.
● Main Content: Contains blog posts with a title, short description, and "Read More" link.
● Footer: Displays copyright information.
● Responsive Design: Uses media queries to adjust the layout for tablet and mobile
screens.
Method / Procedure:
<!DOCTYPE html>
<html>
<head>
<title>Form Validation</title>
<script>
function validateForm() {
var email = [Link]["myForm"]["email"].value; var pwd =
[Link]["myForm"]["password"].value; var emailPattern = /^[^ ]+@[^ ]+\.[a-z]{2,3}$/;
if () { alert("Please enter a valid email."); return false;
}
if ([Link] < 6) {
alert("Password must be at least 6 characters."); return false;
}
alert("Validation successful!"); return true;
}
</script>
</head>
<body>
<h2>Login Form</h2>
<form name="myForm" onsubmit="return validateForm()"> Email: <input type="text"
name="email"><br><br>
Password: <input type="password" name="password"><br><br>
<input type="submit" value="Login">
</form>
</body>
</html>
Input: -
Figure: - 4.1: Input Screenshot of using JavaScript for Validation of Input Data
Output: -
Figure: - 4.2: Output Screenshot of using JavaScript for Validation of Input Data
Figure: - 4.3: Output Screenshot of using JavaScript for Validation of Input Data
Experiment No: 5
Objective: Write a program in XML for creation of DTD, which specifies a set of rules. Create a
style sheet in CSS/ XSL & display the document in internet explorer.
Apparatus/Tools Used :
Hardware Requirement: - Intel Core i5 8GB RAM, 256 GB SSD, Integrated Graphics Card,
1920 X 1080 Display.
● DTD (Document Type Definition): Defines the structure and the legal elements and
attributes of your XML document.
● XML Document: Contains the actual data structured according to the DTD.
● CSS Stylesheet: Styles the XML document to make it visually appealing.
● Displaying in Internet Explorer: Steps to view the styled XML in IE.
Method/Procedure/Overview:
/* General Styles */
body {
font-family: Arial, sans-serif;
background-color: #eef2f3;
margin: 20px;
}
/* Root Element */
employees {
display: block;
margin: 0 auto;
max-width: 800px;
}
/* Employee Entries */
employee {
display: block;
border: 2px solid #4CAF50;
padding: 15px;
margin-bottom: 20px;
border-radius: 8px;
background-color: #ffffff;
box-shadow: 2px 2px 12px rgba(0,0,0,0.1);
}
/* Child Elements */
name {
display: block;
font-size: 1.5em;
color: #333333;
margin-bottom: 10px;
}
/* Hover Effects */
employee:hover {
border-color: #2e7d32;
box-shadow: 4px 4px 16px rgba(0,0,0,0.2);
}
Objective: Create a Java Bean for Employee information (EmpID, Name, Salary, Designation
and Department)
Apparatus/Tools Used :
Hardware Requirement: - Intel Core i5 8GB RAM, 256 GB SSD, Integrated Graphics Card,
1920 X 1080 Display.
● Private Fields: empID, name, salary, designation, and department are private to follow
encapsulation principles.
● Public Getter and Setter Methods: These methods provide access to the private fields.
● No-Argument Constructor: Every JavaBean must have a default no-argument
constructor. This is required for tools that instantiate beans via reflection.
● Serializable Interface: JavaBeans should implement Serializable to allow instances to be
serialized, enabling saving or transferring objects.
● Optional Constructor: An additional constructor with arguments is provided to easily
create Employee objects with data.
● toString() Method: This method is overridden to provide a human-readable
representation of the Employee object, making it easier to print out details during testing.
Method / Procedure:
[Link] (Java Bean for Employee)
import [Link];
Example of Usage:
Input: Source code in terms of Java Bean and Test Bean files
Figure: - 6.1: Input Screenshot for Java Bean and Test Bean
Output:
Figure: - 6.2: Output Screenshot for Java Bean and Test Bean
Experiment No: 7
Objective: Build a command-line utility using [Link] that performs a specific task, such as
converting text to uppercase, calculating the factorial of a number, or generating random
passwords.
Apparatus/Tools Used:
Hardware Requirement: - Intel Core i5 8GB RAM, 256 GB SSD, Integrated Graphics Card,
1920 X 1080 Display.
npm init -y
● Create a JavaScript file (e.g., [Link]): Create a new file called [Link] in your project
directory.
Method / Procedure:
// Command-line menu
function showMenu() {
[Link]("\nPlease choose one of the following options:");
[Link]("1. Convert text to uppercase");
[Link]("2. Calculate factorial of a number");
[Link]("3. Generate a random password");
[Link]("4. Exit");
case '2':
[Link]("Enter a number to calculate its factorial: ", (number) => {
const num = parseInt(number);
if (!isNaN(num) && num >= 0) {
[Link](`Factorial of ${num}: ${calculateFactorial(num)}`);
} else {
[Link]("Please enter a valid non-negative number.");
}
showMenu();
});
break;
case '3':
[Link]("Enter the length of the password (default is 8): ", (length) => {
const pwdLength = parseInt(length) || 8;
[Link](`Generated Password: ${generatePassword(pwdLength)}`);
showMenu();
});
break;
case '4':
[Link]("Exiting...");
[Link]();
break;
default:
[Link]("Invalid choice. Please try again.");
showMenu();
}
});
}
Explanation:
{
"_id": ObjectId("1"),
"name": "John Doe",
"age": 28,
"city": "New York"
},
{
"_id": ObjectId("2"),
"name": "Jane Smith",
"age": 34,
"city": "Los Angeles"
},
{
"_id": ObjectId("3"),
"name": "Alex Johnson",
"age": 22,
"city": "New York"
},
{
"_id": ObjectId("4"),
"name": "Emily Davis",
"age": 29,
"city": "Chicago"
}
// Aggregation pipeline
const pipeline = [
{
// Stage 1: Filter out users with age < 25
$match: {
age: { $gte: 25 }
}
},
{
// Stage 2: Group by 'city' and calculate the average age
$group: {
_id: "$city",
averageAge: { $avg: "$age" },
totalUsers: { $sum: 1 }
}
},
{
// Stage 3: Sort by averageAge in descending order
$sort: {
averageAge: -1
}
}
];
} catch (error) {
[Link]("Error during aggregation:", error);
} finally {
await [Link]();
}
}
runAggregation();
● $match: Filters the documents by selecting only those users whose age is greater than
or equal to 25.
● $group: Groups the documents by the city field. It calculates:
o The average age ($avg) for each group (city).
o The total number of users ($sum) in each city.
● $sort: Sorts the results by averageAge in descending order.
node [Link]
Input: -
Figure: - 8.1: Input Screenshot for developing script using MongoDB's aggregation framework
Output:
Figure: - 8.1: Output Screenshot for developing script using MongoDB's aggregation framework
Experiment No: 9
Objective: Assume four users user1, user2, user3 and user4 having the passwords pwd1, pwd2,
pwd3 and pwd4 respectively. Write a servlet for doing the following:
1. Create a Cookie and add these four user and passwords to this Cookie.
2. Read the user id and passwords entered in the Login form and authenticate with the values
available in the cookies.
Apparatus/Tools Used:
Hardware Requirement: - Intel Core i5 8GB RAM, 256 GB SSD, Integrated Graphics Card,
1920 X 1080 Display.
<?php
setcookie("uid1","user1");
setcookie("pwd1","pwd1");
setcookie("uid2","user2");
setcookie("pwd2","pwd2");
setcookie("uid3","user3");
setcookie("pwd3","pwd3");
setcookie("uid4","user4");
setcookie("pwd4","pwd4");
?>
Login Page
<!DOCTYPE html>
<html>
<head>
<title>User Authentication</title>
</head>
<body>
<h1 align="center">LOGIN</h1>
<tr>
<td><b>User ID</b></td>
</tr>
<tr>
<td><b>Password</b></td>
</tr>
<tr>
</td>
</tr>
</table>
</form>
</body>
</html>
[Link]
<!DOCTYPE html>
<html>
<head>
<title>User Authentication</title>
</head>
<body>
<?php
else{
?>
</body>
</html>
<?php
setcookie("uid1","user1");
setcookie("pwd1","pwd1");
setcookie("uid2","user2");
setcookie("pwd2","pwd2");
setcookie("uid3","user3");
setcookie("pwd3","pwd3");
setcookie("uid4","user4");
setcookie("pwd4","pwd4");
?>
<!DOCTYPE html>
<html>
<head>
<title>User Authentication</title>
</head>
<body>
<h1 align="center">LOGIN</h1>
<tr>
<td><b>User ID</b></td>
</tr>
<tr>
<td><b>Password</b></td>
<tr>
</td>
</tr>
</table>
</form>
</body>
</html>
[Link]
<!DOCTYPE html>
<html>
<head>
<title>User Authentication</title>
</head>
<body>
<?php
}
else if ($_POST["uid"]==$_COOKIE["uid3"] && $_POST["pwd"]==$_COOKIE["pwd3"]) {
else{
?>
</body>
</html>
Testing Scenarios:
1. Successful Login:
○ Input: Username = user1, Password = pwd1
○ Output: Welcome message for user1.
2. Failed Login:
○ Input: Username = user1, Password = wrongpwd
○ Output: "Invalid username or password!" message.
Input: pair of user id and password
Figure: - 9.1: Input Screenshot for Developing Cookies and Adding Cookies
Figure: - 9.2: Input Screenshot for Developing Cookies and Adding Cookies
Figure: - 9.4: Output Screenshot for Developing Cookies and Adding Cookies
Experiment No: 10
Objective: Create a table which should contain at least the following fields: name, password,
email-id, phone number. Write Servlet/JSP to connect to that database and extract data from the
tables and display them. Insert the details of the users who register with the web site, whenever a
new user clicks the submit button in the registration page.
Apparatus/Tools Used:
Hardware Requirement: - Intel Core i5 8GB RAM, 256 GB SSD, Integrated Graphics Card,
1920 X 1080 Display.
To create a web application using Java Servlet and JSP that allows users to register and display
their details stored in a database, we will follow these steps:
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@WebServlet("/RegisterServlet")
public class RegisterServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
1. Set up MySQL: Ensure your MySQL server is running and the userdb database and
users table are created.
2. Deploy the Project: Deploy the web application to a Java EE server like Apache
Tomcat.
3. Access the Registration Page: Navigate to
[Link]
4. Register a User: Fill in the registration form and submit it.
Objective: Write a JSP which insert the details of the 3 or 4 users who register with the web site
by using registration form. Authenticate the user when he submits the login form using the user’s
name and password from the database.
Apparatus/Tools Used:
Hardware Requirement: - Intel Core i5 8GB RAM, 256 GB SSD, Integrated Graphics Card,
1920 X 1080 Display.
To create a JSP application that allows users to register and log in, we need to implement the
following components:
Method / Procedure:
USE userdb;
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@WebServlet("/RegisterServlet")
public class RegisterServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String username = [Link]("username");
String password = [Link]("password");
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String username = [Link]("username");
String password = [Link]("password");
try (Connection connection = [Link](DB_URL, DB_USER,
DB_PASSWORD)) {
String sql = "SELECT * FROM users WHERE username = ? AND password = ?";
try (PreparedStatement statement = [Link](sql)) {
[Link](1, username);
[Link](2, password);
Figure: - 11.1: Input Screenshot for writing JSP for authentication Login Form.
Figure: - 11.2: Input Screenshot for writing JSP for authentication Login Form.
Figure: - 11.3: Output Screenshot for writing JSP for authentication Login Form.
Figure: - 11.4: Output Screenshot for writing JSP for authentication Login Form.
Experiment No: 12
Objective: Design and implement a simple shopping cart example with session tracking API.
Apparatus/Tools Used:
Hardware Requirement: - Intel Core i5 8GB RAM, 256 GB SSD, Integrated Graphics Card,
1920 X 1080 Display.
Method / Procedure:
src
└── [Link]
├── controller
├── model
└── view
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shopping Cart</title>
</head>
<body>
<h1>Welcome to Our Shopping Cart</h1>
<h2>Products</h2>
<div>
<h3>Product 1</h3>
<p>Price: $10</p>
<form action="AddToCartServlet" method="POST">
<input type="hidden" name="productId" value="1">
<input type="hidden" name="productName" value="Product 1">
<input type="hidden" name="productPrice" value="10">
<input type="submit" value="Add to Cart">
</form>
</div>
<div>
<h3>Product 2</h3>
<p>Price: $15</p>
<form action="AddToCartServlet" method="POST">
<input type="hidden" name="productId" value="2">
<input type="hidden" name="productName" value="Product 2">
<input type="hidden" name="productPrice" value="15">
<input type="submit" value="Add to Cart">
</form>
</div>
<div>
<h3>Product 3</h3>
<p>Price: $20</p>
<form action="AddToCartServlet" method="POST">
<input type="hidden" name="productId" value="3">
<input type="hidden" name="productName" value="Product 3">
<input type="hidden" name="productPrice" value="20">
<input type="submit" value="Add to Cart">
</form>
</div>
<h2><a href="[Link]">View Cart</a></h2>
</body>
</html>
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@WebServlet("/AddToCartServlet")
public class AddToCartServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@WebServlet("/RemoveFromCartServlet")
public class RemoveFromCartServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
<web-app xmlns="[Link]
xmlns:xsi="[Link]
xsi:schemaLocation="[Link]
[Link]
version="3.1">
<servlet>
<servlet-name>AddToCartServlet</servlet-name>
<servlet-class>AddToCartServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AddToCartServlet</servlet-name>
<url-pattern>/AddToCartServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>RemoveFromCartServlet</servlet-name>
<servlet-class>RemoveFromCartServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RemoveFromCartServlet</servlet-name>
<url-pattern>/RemoveFromCartServlet</url-pattern>
</servlet-mapping>
</web-app>
Input: -
Figure: - 12.1: Input Screenshot for Cart Page of Website that Tracking API
Figure: - 12.2: Input Screenshot for Cart Page of Website that Tracking API
Output: Webpage Display of Webpage
Figure: - 12.3: Output Screenshot for Cart Page of Website that Tracking API
Objective: A web application that lists all cookies stored in the browser on clicking “List
Cookies” button. Add cookies if necessary.
Apparatus/Tools Used :
Hardware Requirement: - Intel Core i5 8GB RAM, 256 GB SSD, Integrated Graphics Card,
1920 X 1080 Display.
● HTML Structure:
o A button to list the cookies stored in the browser.
o A form to allow users to add new cookies, which includes input fields for the
cookie name and value.
● CSS: Basic styling is applied for better aesthetics.
● JavaScript:
o listCookies(): This function splits the cookie string into individual cookies, then
displays them in an unordered list. If no cookies are found, it displays a message.
o addCookie(event): This function captures the name and value entered by the
user, sets a cookie with a 7-day expiration time, and prevents the default form
submission behavior.
Method / Procedure:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cookie Management</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
width: 400px;
background-color: #f9f9f9;
}
h2 {
text-align: center;
}
#cookieList {
margin-top: 20px;
}
</style>
</head>
<body>
<h2>Cookie Management</h2>
<div id="cookieList"></div>
<h3>Add Cookie</h3>
<form onsubmit="addCookie(event)">
<label for="cookieName">Cookie Name:</label>
<input type="text" id="cookieName" required>
<br><br>
<label for="cookieValue">Cookie Value:</label>
<input type="text" id="cookieValue" required>
<br><br>
<button type="submit">Add Cookie</button>
</form>
<script>
// Function to list cookies
function listCookies() {
const cookies = [Link]('; ');
const cookieListDiv = [Link]('cookieList');
// Add cookie
[Link] = `${name}=${value}; ${expiresString} path=/`;
Input: -
Figure: - 13.1: Input Screenshot for Creating Cookies and List of Cookies.
Output: -
Figure: - 13.2: Output Screenshot for Creating Cookies and List of Cookies.
Figure: - 13.3: Output Screenshot for Creating Cookies and List of Cookies.
Testing the Application
1. Create a File: Save the above code in an HTML file (e.g., [Link]).
2. Open in Browser: Open the file in any modern web browser.
3. Add Cookies: Use the form to add cookies by entering the name and value.
4. List Cookies: Click the "List Cookies" button to see the stored cookies.
Experiment No: 14
Objective: Write a program in java to print the table of the given number using AJAX.
Apparatus/Tools Used:
Hardware Requirement: - Intel Core i5 8GB RAM, 256 GB SSD, Integrated Graphics Card,
1920 X 1080 Display.
Theory:
● User Input:
● The user enters a number in a text box on an HTML page.
● On clicking the "Generate Table" button, a JavaScript function is triggered.
● AJAX Call:
● The JavaScript function creates an XMLHttpRequest and sends a GET request to the server
(Servlet) with the number as a parameter.
Method / Procedure:
<!DOCTYPE html>
<html>
<head>
<title>AJAX Table</title>
<script>
function getTable() {
var num =
[Link]("numbe
r").value; var xhr = new
XMLHttpRequest();
[Link] =
function() {
if([Link] == 4 && [Link] == 200) {
[Link]("result").innerHTML =
[Link];
}
};
[Link]("GET",
"TableServlet?num=" + num, true);
[Link]();
}
</script>
</head>
<body>
Servlet ([Link]):
import [Link].*;
import [Link].*;
import [Link].*;
public class TableServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws IOException { int num =
[Link]([Link]("num"));
[Link]
Type("text/html");
PrintWriter out =
[Link](
);
[Link]("<h3>Multiplication
Table of " + num + "</h3>");
[Link]("<ul>");
for(int i=1; i<=10; i++) {
[Link]("<li>" + num + " x " + i + " = " + (num*i) + "</li>");
}
[Link]("</ul>");
}
Input: -
Figure: - 14.1: Input Screenshot for Displaying Table of any Number Using AJAX.
Output: -
Figure: - 14.2: Output Screenshot for Displaying Table of any Number Using AJAX.