WebTechManual_Final
WebTechManual_Final
Name:
Register no:
Year/Semester: Branch:
UNIVERSITY COLLEGE OF ENGINEERING KANCHEEPURAM
(A Constituent college of Anna University Chennai)
KANCHIPURAM - 631 552
BONAFIDE CERTIFICATE
REGISTER NO
Ex Page
No Date Experiment Title no Signature
1.
Design a web page using HTML that embeds
an image map, defines hot spots, and
displays related information when the hot
spots are clicked.
4.
Install and configure the Apache
Tomcat web server on a local
system.
5.
Design Java servlet programs to invoke
servlets from HTML forms and implement
session tracking
6.
To develop Java programs using JSP and
databases for conducting an online
examination and displaying a student mark
list.
Aim:
To create a web page using HTML that embeds an image map, defines hot spots, and
displays related information when the hot spots are clicked.
Procedure:
Program:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Image Map</title>
<script>
function showInfo(area) { alert("You clicked on: " + area); }
</script>
<style>
body {
background-color: antiquewhite;
}
.page {
color: coral;
font-family: "Courier New", Courier, monospace;
display: flex;
flex-direction: column;
align-items: center;
}
</style>
</head>
<body>
<div class="page">
<div>
<h1>Image Map</h1>
</div>
<div class="image">
<img src="Image.jpg" style="width: 500px; height: 300px; border-radius: 2%"
alt="Sample Image" usemap="#imageMap"
/>
</div>
</div>
<map name="imageMap">
<area shape="rect" coords="50,50,150,150" href="#"
onclick="showInfo('Top Left Rectangle'); return false;" alt="Top Left"
/>
<area shape="circle" coords="300,100,50" href="#"
onclick="showInfo('Right Circle'); return false;" alt="Right Circle"
/>
<area shape="poly" coords="100,200,200,200,150,300" href="#"
onclick="showInfo('Bottom Triangle'); return false;" alt="Bottom Triangle"
/>
</map>
</body>
</html>
Output:
Result:
Thus, to create a web page using HTML that embeds an image map, defines hot spots,
and displays related information when the hot spots are clicked is successfully executed.
Ex.No: 2 Web Page with Cascading Style Sheets
Date:
Aim:
To create a web page that demonstrates inline, internal, and external Cascading Style
Sheets (CSS).
Procedure:
1. Create an HTML file (e.g., styles.html) and a separate CSS file (e.g., styles.css).
2. Apply inline CSS to an element using the style attribute.
3. Include internal CSS within a <style> tag in the HTML <head>.
4. Link the external CSS file using the <link> tag.
5. Design the web page to showcase different styling for text, backgrounds, and layouts.
6. Test the web page in a browser to verify all CSS types are applied correctly.
Program:
Styles.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>CSS Example</title>
<link rel="stylesheet" href="styles.css" />
<style>
/* Internal CSS */
.internal {
background-color: lightblue;
padding: 10px;
font-size: 18px;
}
</style>
</head>
<body>
<h2>CSS Demonstration</h2>
<!-- Inline CSS -->
<p style="color: red; font-weight: bold">This is styled with Inline CSS.</p>
<!-- Internal CSS -->
<p class="internal">This is styled with Internal CSS.</p>
<!-- External CSS -->
<p class="external">This is styled with External CSS.</p>
</body>
</html>
Styles.css
/* External CSS */
.external {
background-color: lightgreen;
padding: 10px;
font-size: 16px;
border: 1px solid black;
}
Output:
Result:
Thus, to create a web page that demonstrates inline, internal, and external Cascading
Style Sheets (CSS) is successfully executed.
Ex.No: 3 Client-Side Form Validation using DHTML
Date:
Aim:
To create a web page with client-side form validation using Dynamic HTML
(DHTML) and JavaScript.
Procedure:
1. Create an HTML file (e.g., form.html) with a form containing input fields (e.g., name,
email, password).
2. Add a submit button and a <div> for displaying validation messages.
3. Write JavaScript to validate form inputs (e.g., check for empty fields, valid email
format).
4. Use DHTML to dynamically update the page with validation messages without
reloading.
5. Test the form in a browser to ensure validations work and messages display correctly.
Program:
Form.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Form Validation</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
h2.title {
color: #007bff;
font-size: 2.5rem;
text-align: center;
margin-bottom: 20px;
text-shadow: 1px 1px 2px rgba(0, 123, 255, 0.5);
font-weight: 700;
}
form {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
width: 300px;
box-sizing: border-box;
}
label {
display: block;
margin-bottom: 5px;
color: #555;
}
input[type="text"],
input[type="email"],
input[type="password"] {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 4px;
transition: border-color 0.3s;
box-sizing: border-box;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
border-color: #007bff;
outline: none;
}
input[type="submit"] {
background-color: #007bff;
color: white;
border: none;
padding: 10px;
border-radius: 4px;
cursor: pointer;
width: 100%;
transition: background-color 0.3s;
font-size: 1rem;
font-weight: 600;
}
input[type="submit"]:hover {
background-color: #0056b3;
}
.error {
color: red;
margin-top: 10px;
}
.success {
color: green;
margin-top: 10px;
font-weight: 600;
}
</style>
</head>
<body>
<div>
<h2 class="title">Form Validation</h2>
<form id="myForm" onsubmit="return validateForm(event)">
<label for="name">Name:</label>
<input type="text" id="name" placeholder="Enter your name" />
<label for="email">Email:</label>
<input type="email" id="email" placeholder="Enter your email" />
<label for="password">Password:</label>
<input
type="password"
id="password"
placeholder="Enter your password"
/>
<input type="submit" value="Submit" />
</form>
<div id="errorMsg"></div>
</div>
<script>
function validateForm(event) {
event.preventDefault();
let name = document.getElementById("name").value;
let email = document.getElementById("email").value;
let password = document.getElementById("password").value;
let errorMsg = document.getElementById("errorMsg");
errorMsg.innerHTML = "";
if (name === "") {
errorMsg.innerHTML += '<p class="error">Name is required</p>';
}
if (!email.includes("@")) {
errorMsg.innerHTML += '<p class="error">Invalid email format</p>';
}
if (password.length < 6) {
errorMsg.innerHTML +=
'<p class="error">Password must be at least 6 characters</p>';
}
if (errorMsg.innerHTML === "") {
errorMsg.innerHTML =
'<p class="success">Form submitted successfully!</p>';
}
return false;
}
</script>
</body>
</html>
Output:
Result:
Thus, to create a web page with client-side form validation using Dynamic HTML
(DHTML) and JavaScript.
Ex.No: 4 Installation of Apache Tomcat Web Server
Date:
Aim:
To install and configure the Apache Tomcat web server on a local system.
Procedure:
Step-1: Download and install JDK (e.g., OpenJDK or Oracle JDK) from
https://openjdk.java.net/ or https://www.oracle.com/java/. Set the JAVA_HOME
environment variable:
Result:
Thus, to install and configure the Apache Tomcat web server on a local system is
successfully executed.
Ex.No: 5 Java Servlets for Form Invocation and Session Tracking
Date:
Aim:
To write Java servlet programs to invoke servlets from HTML forms and implement
session tracking.
Procedure:
Step-1: Install JDK and Apache Tomcat and Install Eclipse IDE with the Tomcat plugin
(e.g., Eclipse IDE for Enterprise Java Developers).
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Form Input</title>
</head>
<body>
<h2>Enter Details</h2>
<label>Name:</label>
</form>
</body>
</html>
web.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_4_0.xsd"
version="4.0">
<servlet>
<servlet-name>FormServlet</servlet-name>
<servlet-class>FormServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>SessionServlet</servlet-name>
<servlet-class>SessionServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FormServlet</servlet-name>
<url-pattern>/formServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SessionServlet</servlet-name>
<url-pattern>/sessionServlet</url-pattern>
</servlet-mapping>
</web-app>
FormServlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
response.setContentType("text/html");
session.setAttribute("username", username);
out.println("<html><body>");
out.println("</body></html>");
SessionServlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
response.setContentType("text/html");
out.println("<html><body>");
out.println("<h2>Session Data</h2>");
} else {
out.println("</body></html>");
}
Step-4: Compile and Deploy:
Step-5: Test:
Aim:
To develop Java programs using JSP and databases for conducting an online
examination and displaying a student mark list.
Prerequisites:
Procedure:
USE StudentDB;
name VARCHAR(100),
marks INT
);
('Alice', 85),
('Bob', 90),
('Charlie', 78);
Step 2: Create Dynamic Web Project in Eclipse
1. Create Package:
• Inside the src folder, right-click and select New > Package.
• Name the package com.lab.
2. Add Java Classes:
• Right-click the com.lab package and select New > Class.
• Create the following classes:
• DBConnection.java
• SubmitExamServlet.java
DBConnection.java
package com.lab;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
try {
Class.forName("com.mysql.cj.jdbc.Driver"); // Register MySQL JDBC driver
} catch (ClassNotFoundException e) {
e.printStackTrace();
SubmitExamServlet.java
package com.lab;
import java.io.IOException;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@WebServlet("/SubmitExamServlet")
// Process POST request and respond with JSON status as plain string
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(jsonResponse);
response.getWriter().flush();
exam.jsp
<html>
<head>
<title>Online Examination</title>
<style>
body {
margin: 0; padding: 0;
</style>
</head>
<body>
<div class="container">
<h1>Online Examination</h1>
<form id="examForm">
</form>
</div>
<div class="modal-content">
<div id="modalMessage"></div>
</div>
</div>
<script>
form.addEventListener('submit', function(event) {
event.preventDefault();
fetch('SubmitExamServlet', {
method: 'POST',
body: formData
})
.then(data => {
if(data.success) {
openModal();
} else {
})
.catch(() => {
openModal();
});
});
function openModal() {
modal.style.display = 'block';
function closeModal() {
modal.style.display = 'none';
form.reset();
// window.location.href = 'marks.jsp';
window.onclick = function(event) {
if (event.target == modal) {
closeModal();
</script>
</body>
</html>
marks.jsp
<html>
<head>
<style>
h1 { color: #333; }
</style>
</head>
<body>
<table>
<tr>
<th>Student ID</th><th>Name</th><th>Marks</th>
</tr>
<%
ResultSet rs = null;
try {
conn = DBConnection.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT * FROM Students");
while (rs.next()) {
%>
<tr>
</tr>
<%
} catch(Exception e) {
} finally {
%>
</table>
</body>
</html>
Step 6: Run the Application
1. Run on Server:
• Right-click the project > Run As > Run on Server.
• Select Apache Tomcat and click Finish.
2. Access the Application:
• Open a web browser and navigate
to http://localhost:8080/OnlineExamApp/exam.jsp.
Step 7: Verify Database Entries
1. Check Submissions:
• You can verify the entries in the Students table using your MySQL client to
ensure the application is functioning correctly.
Result:
Thus, to develop Java programs using JSP and databases for conducting an online
examination and displaying a student mark list is successfully executed.
Ex.No: 7 Programs using XML, Schema, and XSLT/XSL
Date:
Aim:
To create an XML document with a schema for validation and transform it into HTML
using XSLT.
Prerequisites
Procedure:
students.xml
<students>
<student>
<id>1</id>
<name>Alice</name>
<marks>85</marks>
</student>
<student>
<id>2</id>
<name>Bob</name>
<marks>90</marks>
</student>
<student>
<id>3</id>
<name>Charlie</name>
<marks>78</marks>
</student>
</students>
students.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="students">
<xs:complexType>
<xs:sequence>
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
transform.xsl
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<style>
h1 { color: #2a4d69; }
</style>
</head>
<body>
<table>
<tr>
<th>ID</th><th>Name</th><th>Marks</th>
</tr>
<xsl:for-each select="students/student">
<tr>
<td><xsl:value-of select="id"/></td>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="marks"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
1. In Eclipse:
• Right-click students.xml > Validate.
• Eclipse will check the XML content against the students.xsd schema.
• Confirm there are no validation errors.
Step 3: Run the Application
1. Run on Server:
• Right-click the project > Run As > Run on Server.
• Select Apache Tomcat and click Finish.
2. Access the Application:
• Open a web browser and navigate to http://localhost:8080/
XML_Schema/students.xml.
Result:
Thus, to create an XML document with a schema for validation and transform it into
HTML using XSLT.