Web T Lab File
Web T Lab File
INSTITUTE.HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IMS ENGINEERING COLLEGE</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f9;
}
header {
background-color: #004080;
color: white;
padding: 10px 20px;
text-align: center;
}
nav {
background-color: #0066cc;
padding: 10px 20px;
text-align: center;
}
nav a {
color: white;
text-decoration: none;
margin: 0 15px;
font-weight: bold;
}
nav a:hover {
text-decoration: underline;
2|Page
}
section {
padding: 20px;
text-align: left;
}
.department {
margin: 15px 0;
padding: 15px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #ffffff;
}
footer {
background-color: #004080;
color: white;
text-align: center;
padding: 10px 20px;
position: fixed;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<header>
<h1>Welcome to IMS ENGINEERING COLLEGE</h1>
</header>
<nav>
<a href="#cse">CSE Department</a>
<a href="#cs">CS Department</a>
<a href="#ece">ECE Department</a>
<a href="#mech">Mechanical Department</a>
<a href="#contact">Contact Us</a>
</nav>
<section>
<h2>About Our Institute</h2>
<p>IMS ENGINEERING COLLEGE is dedicated to providing quality education and
fostering innovation among students.</p>
<h2 id="cse">Computer Science and Engineering (CSE)</h2>
3|Page
<div class="department">
<p>The CSE Department offers programs focused on software development,
artificial intelligence, and cybersecurity.</p>
</div>
<h2 id="cs">Computer Science (CS)</h2>
<div class="department">
<p>The CS Department offers programs focused on software development,
artificial intelligence,machine learning, system design and cybersecurity.</p>
</div>
<h2 id="ece">Electronics and Communication Engineering (ECE)</h2>
<div class="department">
<p>The ECE Department provides education in telecommunications, VLSI, and
IoT technologies.</p>
</div>
<h2 id="mech">Mechanical Engineering</h2>
<div class="department">
<p>The Mechanical Engineering Department specializes in manufacturing
processes, robotics, and thermodynamics.</p>
</div>
</section>
<footer>
<p>© 2024 IMS ENGINEERING COLLEGE. All Rights Reserved.</p>
</footer>
</body>
</html>
OUTPUT:
4|Page
EXPERIMENT – 02
2. Develop HTML program to design an entry form for student
details/employee information/faculty details.
DETAILS.HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Entry Form</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f9f9f9;
}
header {
background-color: #004080;
color: white;
text-align: center;
padding: 15px;
}
form {
max-width: 500px;
margin: 20px auto;
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
form label {
font-weight: bold;
display: block;
margin: 10px 0 5px;
}
5|Page
form input, form select, form textarea, form button {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
}
form button {
background-color: #004080;
color: white;
border: none;
font-weight: bold;
cursor: pointer;
}
form button:hover {
background-color: #0066cc;
}
</style>
</head>
<body>
<header>
<h1>Entry Form</h1>
</header>
<form action="#" method="post">
<label for="name">Full Name:</label>
<input type="text" id="name" name="name" placeholder="Enter your full name"
required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" placeholder="Enter your email"
required>
<label for="role">Role:</label>
<select id="role" name="role" required>
<option value="">Select Role</option>
<option value="student">Student</option>
<option value="employee">Employee</option>
<option value="faculty">Faculty</option>
</select>
6|Page
<label for="department">Department:</label>
<select id="department" name="department" required>
<option value="">Select Department</option>
<option value="cs">Computer Science</option>
<option value="cse">Computer Science and Engineering</option>
<option value="ece">Electronics and Communication</option>
<option value="mech">Mechanical</option>
<option value="civil">Civil</option>
</select>
<label for="address">Address:</label>
<textarea id="address" name="address" rows="4" placeholder="Enter your
address"></textarea>
<button type="submit">Submit</button>
</form>
</body>
</html>
7|Page
OUTPUT:
8|Page
EXPERIMENT – 03
3. Develop a responsive website using CSS and HTML. Website may be
for tutorial/blogs/commercial website.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Blog</title>
<style>
/* General Reset */
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
line-height: 1.6;
background-color: #f4f4f9;
color: #333;
}
header {
background: #004080;
color: white;
padding: 20px 10px;
text-align: center;
}
header h1 {
font-size: 2rem;
margin-bottom: 5px;
}
header p {
9|Page
font-size: 1rem;
}
nav {
display: flex;
justify-content: center;
background: #0066cc;
padding: 10px;
}
nav a {
color: white;
text-decoration: none;
margin: 0 15px;
font-size: 1rem;
}
nav a:hover {
text-decoration: underline;
}
.container {
max-width: 1100px;
margin: 20px auto;
padding: 0 15px;
}
.grid {
display: flex;
flex-wrap: wrap;
gap: 20px;
}
.card {
flex: 1 1 calc(33.333% - 20px);
background: white;
padding: 15px;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
10 | P a g e
transition: transform 0.3s ease;
}
.card:hover {
transform: scale(1.05);
}
.card img {
max-width: 100%;
border-radius: 8px;
}
.card h3 {
font-size: 1.2rem;
margin: 10px 0;
}
.card p {
font-size: 0.9rem;
color: #555;
}
footer {
background: #004080;
color: white;
text-align: center;
padding: 10px;
margin-top: 20px;
}
/* Responsive Design */
@media (max-width: 768px) {
.card {
flex: 1 1 calc(50% - 20px);
}
}
11 | P a g e
flex: 1 1 100%;
}
nav {
flex-wrap: wrap;
}
nav a {
margin: 5px 10px;
}
}
</style>
</head>
<body>
<header>
<h1>Welcome to My Blog</h1>
<p>Your daily dose of knowledge</p>
</header>
<nav>
<a href="#home">Home</a>
<a href="#about">About</a>
<a href="#blogs">Blogs</a>
<a href="#contact">Contact</a>
</nav>
<div class="container">
<h2>Latest Posts</h2>
<div class="grid">
<div class="card">
<img src="" alt="Post Image">
<h3>Understanding Responsive Design</h3>
<p>Learn how to make your website look great on any device.</p>
</div>
<div class="card">
<img src="" alt="Post Image">
<h3>Top 10 CSS Tricks</h3>
<p>Discover the most useful CSS techniques for developers.</p>
</div>
12 | P a g e
<div class="card">
<img src="" alt="Post Image">
<h3>JavaScript for Beginners</h3>
<p>A guide to getting started with JavaScript programming.</p>
</div>
</div>
</div>
<footer>
<p>© 2024 My Blog. All rights reserved.</p>
</footer>
</body>
</html>
OUTPUT:
13 | P a g e
EXPERIMENT – 04
4. Develop Java script application to validate input data in registration
form.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Form Validation</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f9;
}
.container {
max-width: 500px;
margin: 50px auto;
padding: 20px;
background: white;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
margin-bottom: 20px;
}
form label {
display: block;
font-weight: bold;
margin-bottom: 5px;
}
14 | P a g e
form input {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
}
form button {
width: 100%;
padding: 10px;
background-color: #004080;
color: white;
border: none;
border-radius: 5px;
font-weight: bold;
cursor: pointer;
}
form button:hover {
background-color: #0066cc;
}
.error {
color: red;
font-size: 0.9rem;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
<h2>Registration Form</h2>
<form id="registrationForm">
<label for="name">Name:</label>
<input type="text" id="name" name="name" placeholder="Enter your
name">
<div id="nameError" class="error"></div>
15 | P a g e
<label for="email">Email:</label>
<input type="email" id="email" name="email" placeholder="Enter your
email">
<div id="emailError" class="error"></div>
<label for="password">Password:</label>
<input type="password" id="password" name="password"
placeholder="Enter your password">
<div id="passwordError" class="error"></div>
<script>
function validateForm() {
// Clear all errors
document.getElementById("nameError").innerText = "";
document.getElementById("emailError").innerText = "";
document.getElementById("passwordError").innerText = "";
document.getElementById("phoneError").innerText = "";
// Validate Name
if (name === "") {
document.getElementById("nameError").innerText = "Name is
required.";
16 | P a g e
isValid = false;
}
// Validate Email
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
if (!emailPattern.test(email)) {
document.getElementById("emailError").innerText = "Enter a valid
email address.";
isValid = false;
}
// Validate Password
if (password.length < 6) {
document.getElementById("passwordError").innerText = "Password
must be at least 6 characters long.";
isValid = false;
}
OUTPUT:
17 | P a g e
18 | P a g e
19 | P a g e
EXPERIMENT – 05
5. Develop a markup language to store employee details and validate
it using DTD. Create a style sheet in CSS/ XSL & display the document
in Browser.
Employees.xml
Employees.dtd
20 | P a g e
<!ELEMENT Salary (#PCDATA)>
Style.xsl
21 | P a g e
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
OUTPUT:
22 | P a g e
EXPERIMENT – 06
6. Develop Client Server application using Socket Programming in java.
Server.java
import java.io.*;
import java.net.*;
// Send a response
writer.println("Server: Message received -> " + clientMessage);
// Exit condition
if ("bye".equalsIgnoreCase(clientMessage)) {
System.out.println("Client disconnected");
break;
}
23 | P a g e
}
socket.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
Client.java
import java.io.*;
import java.net.*;
24 | P a g e
message = consoleReader.readLine(); // Read user input
writer.println(message); // Send message to server
// Exit condition
if ("bye".equalsIgnoreCase(message)) {
break;
}
socket.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
Client OUPUT:
Server OUTPUT:
25 | P a g e
EXPERIMENT -07
7. Develop application in java servlet to add and retrieve cookies to
maintain client data.
(Assume four users user1, user2, user3 and user4 having the
passwords pwd1, pwd2, pwd3 and pwd4 respectively).
login.html
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
26 | P a g e
if (authenticated) {
// Create cookies for the user
Cookie userCookie = new Cookie("username", username);
response.addCookie(userCookie);
out.println("<h2>Login Successful!</h2>");
out.println("<a href='dashboard'>Go to Dashboard</a>");
} else {
out.println("<h2>Invalid username or password!</h2>");
out.println("<a href='login.html'>Try Again</a>");
}
}
}
DashboardServlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
// Retrieve cookies
Cookie[] cookies = request.getCookies();
String username = null;
if (cookies != null) {
for (Cookie cookie : cookies) {
if (cookie.getName().equals("username")) {
username = cookie.getValue();
break;
27 | P a g e
}
}
}
if (username != null) {
out.println("<h2>Welcome, " + username + "!</h2>");
out.println("<a href='logout'>Logout</a>");
} else {
out.println("<h2>No user logged in!</h2>");
out.println("<a href='login.html'>Login</a>");
}
}
}
LogoutServlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
// Clear cookies
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
cookie.setMaxAge(0); // Delete cookie
response.addCookie(cookie);
}
}
28 | P a g e
}
Login.html
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
</head>
<body>
<h2>Login</h2>
<form action="login" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
<button type="submit">Login</button>
</form>
</body>
</html>
Web.xml
<web-app>
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>DashboardServlet</servlet-name>
<servlet-class>DashboardServlet</servlet-class>
29 | P a g e
</servlet>
<servlet-mapping>
<servlet-name>DashboardServlet</servlet-name>
<url-pattern>/dashboard</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>LogoutServlet</servlet-name>
<servlet-class>LogoutServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LogoutServlet</servlet-name>
<url-pattern>/logout</url-pattern>
</servlet-mapping>
</web-app>
OUTPUT:
30 | P a g e
Experiment – 08
8. Develop Login and Registration process application using Servlet
Index.html
<!DOCTYPE html>
<html>
<head>
<title>Login & Registration</title>
</head>
<body>
<h2>Registration</h2>
<form action="register" method="post">
<label for="regUsername">Username:</label>
<input type="text" id="regUsername" name="username" required><br><br>
<label for="regPassword">Password:</label>
<input type="password" id="regPassword" name="password" required><br><br>
<button type="submit">Register</button>
</form>
<h2>Login</h2>
<form action="login" method="post">
<label for="loginUsername">Username:</label>
<input type="text" id="loginUsername" name="username" required><br><br>
<label for="loginPassword">Password:</label>
<input type="password" id="loginPassword" name="password"
required><br><br>
<button type="submit">Login</button>
</form>
</body>
</html>
RegisterServlet.java
31 | P a g e
import java.io.*;
import java.util.HashMap;
import javax.servlet.*;
import javax.servlet.http.*;
LoginServlet.java
import java.io.*;
32 | P a g e
import javax.servlet.*;
import javax.servlet.http.*;
// Validate credentials
if (RegisterServlet.getUsers().containsKey(username) &&
RegisterServlet.getUsers().get(username).equals(password)) {
out.println("<h2>Login successful! Welcome, " + username + ".</h2>");
} else {
out.println("<h2>Login failed! Invalid username or password.</h2>");
}
Web.xml
<web-app>
<servlet>
<servlet-name>RegisterServlet</servlet-name>
<servlet-class>RegisterServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RegisterServlet</servlet-name>
<url-pattern>/register</url-pattern>
</servlet-mapping>
<servlet>
33 | P a g e
<servlet-name>LoginServlet</servlet-name>
<servlet-class>LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
</web-app>
OUTPUT:
34 | P a g e
Experiment – 09
9. Develop a simple JSP application displaying user name and his city.
Index.jsp
<!DOCTYPE html>
<html>
<head>
<title>User Information</title>
</head>
<body>
<h2>Enter Your Details</h2>
<form action="display.jsp" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br><br>
<label for="city">City:</label>
<input type="text" id="city" name="city" required><br><br>
<button type="submit">Submit</button>
</form>
</body>
</html>
Display.jsp
35 | P a g e
<body>
<h2>User Details</h2>
<%
// Retrieve data from the form
String name = request.getParameter("name");
String city = request.getParameter("city");
%>
OUTPUT:
36 | P a g e
EXPERIMENT – 10
10. Develop a registration process using JavaBeans and JSP.
User.java
package beans;
37 | P a g e
}
}
Register.jsp
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
<button type="submit">Register</button>
</form>
</body>
</html>
Process.jsp
38 | P a g e
<head>
<title>Registration Successful</title>
</head>
<body>
<h2>Registration Confirmation</h2>
39 | P a g e