HTML
HTML
Design a HTML page describing your profile in one paragraph. Design in such a way that it has
a heading, a horizontal rule, three links and your photo. Also, write three HTML documents for
the links. Include facilities for forward, backward and HOME.
Aim: Design a HTML page describing your profile in one paragraph. Design in such a way hat it has a heading,
a horizontal rule, three links and your photo. Also, write three HTML documents for the links. Include facilities
for forward, backward and HOME.
PROCEDURE:
The following tags are used.
TAG DESCRIPTION
<HTML> Defines an HTML document
<body> Defines the document’s body
<h1>to<h6> Defines header 1 to header6
<p> Defines a paragraph
<br> Inserts a single line break
<hr> Defines a horizontal rule
<!--> Defines a comment
<bgcolor> Defines the background color
<img src> It is used to add images in the web page
<href> It is used to make link with other web page
<title> Defines the document’s title
PROGRAM:
Profile.html
<html>
<head></head>
<title>1st_practical</title>
<body align="centre">
1. a_link.html
<html>
<title>1st_practical</title>
<head>First link</head><br>
<body>
<a href="profile.html">Home</a><br>
<a href="b_link.html">Forward</a><br>
</body>
</html>
2. b_link.html
<html>
<title>1st_practical</title>
<head>Second link</head>
<body>
<br>
<a href="profile.html ">Home</a><br>
<a href="c_link.html">Forward</a><br>
<a href="a_link.html">Backward</a><br>
</body>
</html>
3. c_link.html
<html>
<title>1st_practical</title>
<head>Third link</head><br>
<body>
<a href="profile.html ">Backward</a><br>
<a href="1_practical.html">Home</a><br>
</body>
</html>
Practical-2
Design a HTML page about computer languages. List the language. Each Language’s name is
a link. Prepare separate HTML documents for each language and call them in the appropriate
link.
AIM: Design a HTML page about computer languages. List the languages. Each languages name is
link. Prepare separate HTML documents for each language and call them in the appropriate link.
PROCEDURE:
The following tags are used
<HTML> Defines an HTML document
<body> Defines the document’s body
<h1>to<h6> Defines header 1 to header6
<p> Defines a paragraph
<br> Inserts a single line break
<hr> Defines a horizontal rule
<!--> Defines a comment
<bgcolor> Defines the background color
<img src> It is used to add images in the web page
<href> It is used to make link with other web page
<title> Defines the document’s title
Program:
Second.html
<html>
<head>
Language
</head>
<body>
<br>
<a href="friend1.html">Java</a><br>
<a href="friend2.html">C</a><br>
<a href="friend3.html">C++</a><br>
</body>
</html>
Friend1.html
<html>
<head></head>
<body>
<p>Java is a object oriented language</p>
<br>
<a href="second.html">Home</a><br>
</body>
</html>
Friend2.html
<html>
<head></head>
8
<body>
<p>C is a object oriented language</p>
<br>
<a href="second.html">Home</a><br>
</body>
</html>
Friend3.html
<html>
<head></head>
<body>
<p>C++ is a procedure as well as object oriented</p>
<br>
<a href="second.html">Home</a><br>
</body>
</html>
Practical-3
Design a single page website for your polytechnic containing a description of the
courses offered. It should also contain some general information about the college
such as its history, the campus, its unique features and so on. The site should be
colored and each section should have a different color.
AIM:
Design a single page website for your polytechnic containing a description of the courses offered.
It should also contain some general information about the college such as its history, the campus,
and its unique features and so on. The site should be colored and each section should have a
different color.
PROCEDURE:
The following tags are used.
TAG DESCRIPTION
<HTML> Defines an HTML document
<body> Defines the document’s body
<h1>to<h6> Defines header 1 to header6
<p> Defines a paragraph
<br> Inserts a single line break
<hr> Defines a horizontal rule
<!--> Defines a comment
<bgcolor> Defines the background color
<img src> It is used to add images in the web page
<href> It is used to make link with other web page
<li> It is used to list the item
<ol> It is used to list the item with number as index
<ul> It is used to list the item with bullets as index
<title> Defines the document’s title
PROGRAM:
<html>
<h1 align="CENTER">GOVERMENT POLYTECHNIC COLLEGE</h1>
</a>
h1 {
a {
}
</style>
</font>
<hr>
<font color="Green">
</font>
</h2>
</body>
</html>
Practical-4
Develop a web page using CSS to create a time table for the class using different border style.
AIM:
Write a program using CSS to create a time table for the class.
PROCEDURE:
1. Open a new file.
2. Write the basic HTML tags.
3. <style> used to change the font-type, size and color of the page.
4. <table> used to create table.
The following tags are present inside the table tags
i) <TR> used to create horizontal rows of cells.
ii) <TH> used to define the heading of cells in the table.
iii) <TD> used to define the data of each cells in the table.
5. Close the all tags.
PROGRAM: TIME TABLE USING CSS
<html>
<head>
<title>Time Table</title>
<style type="text/css"> h1 {
font-family: arial, helvita; font-size: 16pt;
color: red;
}
body {
font-family: times, serif; font-size: 20pt;
color: white; background: blue;
}
h2 {
font-family: monospace, sans-serif; font-size: 18pt;
color: red;
}
</style>
</head>
<body>
<table border="5" align="center">
<tr>
<td>
<h2>Hour/Days</h2>
</td>
<td>
<h2>Monday</h2>
</td>
<td>
<h2>Tuesday</h2>
</td>
<td>
<h2>Wednesday</h2>
</td>
<td>
<h2>Thursday</h2>
</td>
<td>
<h2>Friday</h2>
</td>
<td>
<h2>Saturday</h2>
</td>
</tr>
<tr>
<td>
<h2>10A.M-10.50A.M</h2>
</td>
<h1>
<td>RDBMS</td>
<td>CSO</td>
<td>RDBMS</td>
<td>OOC/td>
<td>OOC LAB</td>
<td>DS/td>
</h1>
</tr>
<tr>
<td>
<h2>10.50A.M-11.40A.M</h2>
</td>
<h1>
</tr>
<tr>
<td>
<h1>
<td>IWT</td>
<td>RDBMS LAB</td>
<td>IWT</td>
<td>IWT</td>
<td>OOC LAB</td>
<td>IWT</td>
</h1>
<tr>
<td>
<h2>11.40A.M-12.30P.M</h2>
</td>
<h1>
<h1>
<td>CSO</td>
<td>CNS</td>
<td>CNS</td>
<td>DS</td>
<td>CNS</td>
<td>OOC</td>
</h1>
<tr>
<td>
<h2>12.30P.M-1.20P.M</h2>
</td>
<h1>
</tr>
<tr>
<td>
<h1>
<td>CSO</td>
<td>CNS</td>
<td>DS</td>
<td>RDBMS</td>
<td>RDBMS</td>
<td>OOC</td>
</h1>
<h2>4.20P.M-5.10P.M</h2>
</td>
<h1>
<td>G.P</td>
<td>G.P</td>
<td>DS</td>
<td>RDBMS LAB</td>
<td>RDBMS LAB</td>
<td>DS</td>
</h1>
</tr>
<var></var>
</table>
</body>
</body>
</html>
PRACTICAL-5
a) Write a Java script code that converts the entered text to uppercase
<!DOCTYPE html>
<html>
<head>
<title>lowerCase To upperCase</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f3f3f3;
padding: 20px;
}
h1 {
color: #333;
}
span {
font-weight: bold;
margin-bottom: 10px;
display: block;
}
input[type="text"] {
border: 1px solid #ccc;
border-radius: 8px;
height: 30px;
padding: 5px;
font-size: 16px;
width: 200px;
background-color: #fff;
transition: border-color 0.3s ease;
}
input[type="text"]:focus {
border-color: #8a2be2;
}
button {
padding: 10px 20px;
background-color: #8a2be2;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #9c4ae6;
}
.output-container {
margin-top: 20px;
padding: 10px;
border-radius: 4px;
font-size: 16px;
color: #333;
}
.input-output {
background-color: #fff;
border: 1px solid #ccc;
margin-bottom: 10px;
padding: 10px;
}
.output {
background-color: #f8f8f8;
border: 1px solid #ccc;
padding: 10px;
}
</style>
</head>
<body>
<h1>lowerCase To upperCase</h1>
<span>Enter Text:</span>
<input id="info" type="text" />
<button onclick="convertUppercase()">Submit</button>
<div class="output-container">
<div class="input-output">
<strong>Input:</strong>
<span id="input-output"></span>
</div>
<div class="output">
<strong>Output:</strong>
<span id="output"></span>
</div>
</div>
<script>
function convertUppercase() {
let input = document.getElementById("info").value;
let upperCase = input.toUpperCase();
let inputOutputElement = document.getElementById("input-output");
inputOutputElement.textContent = input;
let outputElement = document.getElementById("output");
outputElement.textContent = upperCase;
}
</script>
</body>
</html>
Output:
b) Write a Java script code to validate the username and password. The
username and password are stored in variables.
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
background-color: #fff;
padding: 40px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
max-width: 400px;
width: 100%;
}
h1 {
text-align: center;
color: #333;
margin-bottom: 30px;
}
label {
display: block;
margin-bottom: 10px;
color: #555;
font-weight: bold;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
margin-bottom: 20px;
}
input[type="button"] {
width: 100%;
padding: 10px;
background-color: #4caf50;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}
input[type="button"]:hover {
background-color: #45a049;
}
.message {
text-align: center;
margin-top: 20px;
font-weight: bold;
}
.message.success {
color: #4caf50;
}
.message.error {
color: #f44336;
}
</style>
<script>
let username = "myusername";
let password = "mypassword";
function validateCredentials() {
let inputUsername = document.getElementById("username").value;
let inputPassword = document.getElementById("password").value;
if (inputUsername === username && inputPassword === password) {
displayMessage("Login successful", "success");
} else {
displayMessage("Invalid username or password", "error");
}
}
function displayMessage(message, type) {
let messageElement = document.getElementById("message");
messageElement.innerText = message;
messageElement.classList.add(type);
}
</script>
</head>
<body>
<div class="container">
<h1>Login Page</h1>
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username">
<label for="password">Password:</label>
<input type="password" id="password" name="password">
<input type="button" value="Submit" onclick="validateCredentials()">
<p id="message" class="message"></p>
</form>
</div>
</body>
</html>
Output
PRACTICAL-6
Write a Java Script code using frames and Events (When a cursor moves over an
object it should display the specification of the object in another frame )
Index.html
<!DOCTYPE html>
<html>
<head>
<title>Object Specifications</title>
<script>
function displaySpecifications(specs) {
var specsFrame = parent.frames['specs_frame'];
if (specsFrame) {
specsFrame.document.getElementById('specs_content').innerHTML = specs;
}
}
</script>
</head>
<frameset cols="50%,50%">
<frame src="objects.html" name="objects_frame">
<frame src="specs.html" name="specs_frame">
</frameset>
<noframes></noframes>
</html>
Objects.html
<!DOCTYPE html>
<html>
<head>
<title>Objects</title>
<style>
body {
background-color: rgb(199, 202, 199);
font-family: Arial, sans-serif;
}
h2 {
color: #333;
}
.object {
padding: 10px;
border: 1px solid #ccc;
cursor: pointer;
background-color: #80be1c;
margin-bottom: 10px;
color: #010105;
}
.object:hover {
background-color: #ddd;
}
</style>
<script>
function showSpecifications(specs) {
parent.displaySpecifications(specs);
}
</script>
</head>
<body>
<h2>Objects</h2>
<div class="object" onmouseover="showSpecifications('Object 1 specifications.')">Object 1</div>
<div class="object" onmouseover="showSpecifications('Object 2 specifications.')">Object 2</div>
<div class="object" onmouseover="showSpecifications('Object 3 specifications.')">Object 3</div>
</body>
</html>
specs.html
<!DOCTYPE html>
<html>
<head>
<title>Specifications</title>
<style>
body {
background-color: rgb(199, 202, 199);
font-family: Arial, sans-serif;
}
h2 {
color: #0e8b85;
}
#specs_content {
padding: 10px;
border: 1px solid #ccc;
background-color: #17739e;
color: #e9e3e3;
}
</style>
</head>
<body>
<h2>Specifications</h2>
<div id="specs_content"></div>
</body>
</html>
Output
PRACTICAL-7
Create a site containing banner advertisement at the top of the page. The ads are
changed every 10 or 15 seconds.
Index.html
<!DOCTYPE html>
<html>
<head>
<title>Rotating Banner Ads</title>
<style>
#banner {
height: 200px;
width: 100%;
background-color: #f2f2f2;
display: flex;
align-items: center;
justify-content: center;
}
#banner img {
max-width: 100%;
max-height: 100%;
}
</style>
</head>
<body>
<div id="banner">
<img id="adImage" src="" alt="Banner Ad">
</div>
<script>
// Array of banner ad images
var adImages = [
"lg.jpg",
"samsung.jpg",
"panasonic.jpg"
];
Output:
1st ad
2nd ad
Third ad
PRACTICAL 8
Write Jquery Program for Count the number of milliseconds between the two
click events on a paragraph.
<!DOCTYPE html>
<html>
<head>
<title>Click Event Timer</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body {
background-color: #f1f1f1;
font-family: Arial, sans-serif;
}
p{
padding: 10px;
background-color: #3498db;
color: #fff;
font-size: 18px;
cursor: pointer;
text-align: center;
}
</style>
<script>
$(document).ready(function () {
var startTime; // Variable to store the start time
$("p").click(function () {
if (!startTime) {
// First click event
startTime = new Date().getTime(); // Get the current time
} else {
// Second click event
var endTime = new Date().getTime(); // Get the current time
var timeDiff = endTime - startTime; // Calculate the time difference in milliseconds
alert("Time between clicks: " + timeDiff + " milliseconds");
// Reset the start time for the next click event
startTime = null;
}
});
});
</script>
</head>
<body>
<p>Click here</p>
</body>
</html>
Output
Setcookie.jsp
<%@page language="java"import="java.util.*"%>
<%
String username=request.getParameter("username");
if(username==null)username="";
Date now = new Date();
String timestamp = now.toString();
Cookie cookie =new Cookie ("username",username);
cookie.setMaxAge(365*24*60*60);
response.addCookie(cookie);
%>
<html>
<head>
<title>Cookie Saved</title>
</head>
<body>
<p><a href="showcookievalue.jsp">Next page to view the cookie value</a></p>
</body>
</html>
showcookievalue.jsp
<%@ page language="java"%>
<%
String cookieName="username"; Cookie
cookies[]=request.getCookies(); Cookie
myCookie=null; if(cookies!=null)
{
for(int i=0;i<cookies.length;i++)
{
if(cookies[i].getName().equals(cookieName))
{
myCookie=cookies[i];
break;
}
}
}
%>
<html>
<head> <title> Show saved cookie</title> </head>
<body>
<%
if(myCookie==null)
{
%>
No Cookie found with the name<%=cookieName%>
<%
}
else
{
%>
<p>welcome:<%=myCookie.getValue()%>
<%
}
%>
</body>
</html>
OUTPUT
h2 {
text-align: center;
color: #333;
margin-bottom: 30px;
}
label {
display: block;
margin-bottom: 10px;
color: #555;
font-weight: bold;
}
input[type="text"] {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
margin-bottom: 20px;
}
button[type="submit"] {
width: 100%;
padding: 10px;
background-color: #4caf50;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button[type="submit"]:hover {
background-color: #45a049;
}
p.definition {
color: #333;
font-weight: bold;
text-align: center;
}
p.error {
color: #f44336;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<h2>Get Definition</h2>
<form action="definitions.jsp" method="get">
<label for="itemName">Enter item name:</label>
<input type="text" id="itemName" name="name" required>
<button type="submit">Get Definition</button>
</form>
</div>
</body>
</html>
Definitions.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<title>Definitions</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
background-color: #fff;
padding: 40px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
max-width: 400px;
width: 100%;
}
h2 {
text-align: center;
color: #333;
margin-bottom: 30px;
}
label {
display: block;
margin-bottom: 10px;
color: #555;
font-weight: bold;
}
input[type="text"] {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
margin-bottom: 20px;
}
button[type="submit"] {
width: 100%;
padding: 10px;
background-color: #4caf50;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button[type="submit"]:hover {
background-color: #45a049;
}
p.definition {
color: #333;
font-weight: bold;
text-align: center;
}
p.error {
color: #f44336;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<h2>Get Definition</h2>
<form action="definitions.jsp" method="get">
<label for="itemName">Enter item name:</label>
<input type="text" id="itemName" name="name" required>
<button type="submit">Get Definition</button>
</form>
<%-- Define the string arrays --%>
<%!
String[] names = {
"Item 1",
"Item 2",
"Item 3",
"Item 4",
"Item 5"
};
String[] definitions = {
"Definition 1", "Definition 2","Definition 3","Definition 4", "Definition 5"
};
%>
<%-- Get the requested name parameter --%>
<% String requestedName = request.getParameter("name"); %>
<%-- Loop through the names array to find a match --%>
<% boolean found = false;
for (int i = 0; i < names.length; i++) {
if (names[i].equalsIgnoreCase(requestedName)) {
// Match found, display the definition
%>
<p class="definition"><%= definitions[i] %></p>
<% found = true;
break;
}
}
if (!found && requestedName != null && !requestedName.isEmpty()) {
// No match found, display an error message
%>
<p class="error">No definition found for "<%= requestedName %>".</p>
<% } %>
</div>
</body>
</html>
Output
PRACTICAL-13
Write a JSP code to upload data from client side.
Index.html
<!DOCTYPE html>
<html>
<head>
<title>File Upload</title>
<style>
body {
background-color: #f5f5f5;
font-family: Arial, sans-serif;
text-align: center;
}
h2 {
color: #333;
margin-top: 30px;
}
form {
margin-top: 20px;
}
input[type="file"] {
padding: 10px;
border: none;
background-color: #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
button[type="submit"] {
padding: 10px 20px;
border: none;
background-color: #4CAF50;
color: #fff;
cursor: pointer;
}
</style>
</head>
<body>
<h2>File Upload</h2>
<form action="upload.jsp" method="post" enctype="multipart/form-data">
<input type="file" name="file" required>
<br>
<button type="submit">Upload</button>
</form>
</body>
</html>
Upload.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@ page import="java.io.*, javax.servlet.*, javax.servlet.http.*" %>
<%@ page import="org.apache.commons.io.IOUtils" %>
<%
// Specify the directory where uploaded files will be stored
String uploadDir = "C:/uploads"; // Update this with your desired directory
// Create the upload directory if it doesn't exist
File dir = new File(uploadDir);
if (!dir.exists()) {
dir.mkdirs();
}
// Process the file upload
Part filePart = request.getPart("file");
String fileName = getFileName(filePart);
InputStream fileContent = filePart.getInputStream();
Output
PRACTICAL-14
Write a program to check how many users have visited a website. Use
Application object.
appobj.jsp
<html>
<head>
<title>Using the Application Object</title>
</head>
<body>
<h1>Using the Application Object</h1>
<%Integer counter=(Integer)session.getAttribute("counter"); String heading=null;
if(counter==null)
{
counter=new Integer(1);
}
else
{
counter=new Integer(counter.intValue()+1);
}
session.setAttribute("counter",counter);Integer
applicationCounter=(Integer)application.getAttribute("applicationCounter"); if(applicationCounter==null)
{
applicationCounter=new Integer(1);
}
else
{
applicationCounter=new Integer(applicationCounter.intValue()+1);
}
application.setAttribute("applicationCounter",applicationCounter);
%>
You have visited this page<%=counter%>times.
<br>
This page has been visited by all users<%=applicationCounter%>times.
</body>
</html>
Output
PRACTICAL-15
Write a Code in Java Script to count number of times you move over a link or
record.
<!DOCTYPE html>
<html>
<head>
<title>Practical 15</title>
<style>
#hoverCounter {
background-color: rgb(248, 248, 224);
display: flex;
align-items: center;
font-family: Arial, sans-serif;
font-size: 18px;
}
#myLink {
margin-right: 10px;
color: blue;
text-decoration: underline;
cursor: pointer;
font-family: Comic Sans MS;
}
#countDisplay {
background-color: #f2f2f2;
padding: 5px 10px;
border-radius: 4px;
}
</style>
</head>
<body>
<div id="hoverCounter">
<pre style="color:green; font-size: xx-large; font-family:Comic Sans MS">Click here and see the magic
</pre></br>
<a id="myLink" href="#">Link</a>
<span id="countDisplay">0</span>
</div>
<script>
// Get the link and count display element
const link = document.getElementById('myLink');
const countDisplay = document.getElementById('countDisplay');
// Add an event listener for 'animationend' event to remove the animation class
countDisplay.addEventListener('animationend', () => {
countDisplay.classList.remove(animationClass);
});
// Add an event listener for 'click' event to animate the count display
countDisplay.addEventListener('click', () => {
countDisplay.classList.add(animationClass);
});
</script>
</body>
</html>
Output