0% found this document useful (0 votes)
3 views26 pages

Delicious Restaurant Offers and Menu

The document contains multiple HTML and Java files for various applications including a restaurant website, college website, digital library, university exam results, an India map with hotspots, an online banking application, a shopping catalog, and a student login system. Each section includes relevant HTML structures, styles, and Java code for server-side processing. The content is designed to showcase different functionalities such as user interaction, data display, and form handling.

Uploaded by

siva9366651116
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views26 pages

Delicious Restaurant Offers and Menu

The document contains multiple HTML and Java files for various applications including a restaurant website, college website, digital library, university exam results, an India map with hotspots, an online banking application, a shopping catalog, and a student login system. Each section includes relevant HTML structures, styles, and Java code for server-side processing. The content is designed to showcase different functionalities such as user interaction, data display, and form handling.

Uploaded by

siva9366651116
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Restaurent:
<!DOCTYPE html>
<html>
<head>
<title>Delicious Restaurant</title>
<style>
body {
font-family: Arial;
background-color: #fff7e6;
text-align: center;
}
h2 {
color: #e67300;
}
img {
border-radius: 10px;
box-shadow: 0 0 10px #aaa;
}
</style>
</head>
<body>
<h2> Welcome to Delicious Restaurant </h2>
<p>Click on your favorite combo to view the offer!</p>

<img src="[Link]" usemap="#offers" width="400" height="300" alt="Food Menu">


<map name="offers">
<area shape="rect" coords="10,10,120,120" alt="Pizza Combo"
onclick="alert('Pizza Combo - ₹299 Only!')">
<area shape="rect" coords="150,10,270,120" alt="Burger Combo"
onclick="alert('Burger Combo - ₹199 Only!')">
</map>
</body>
</html>

1. college website
<!DOCTYPE html>
<html>
<head>
<title>College Website</title>

<!-- External Style Sheet -->


<link rel="stylesheet" href="[Link]">
<!-- Embedded (Internal) Style Sheet -->
<style>
body {
background-color: lightgrey;
text-align: center;
}
h1 {
color: darkblue;
}
1
</style>
</head>
<body>
<h1>GCE Dharmapuri</h1>
<p>Welcome to our college website!</p>
<!-- Inline Style Sheet -->
<h2 style="color: green;">Department of Computer Science</h2>
<h2 style="color: green;">Department of ECE</h2>
<h2 style="color: green;">Department of EEE</h2>
<h2 style="color: green;">Department of Civil</h2>
<h2 style="color: green;">Department of Mechanical</h2>
<footer>
<p>© 2025 GCE Dharmapuri</p>
</footer>
</body>
</html>

[Link] library

[Link]

<!DOCTYPE html>

<html>

<head><title>Digital Library Login</title></head>

<body>

<h2>Digital Library Login</h2>

<form action="Library" method="post">

Username: <input type="text" name="username" required><br><br>

Password: <input type="password" name="password" required><br><br>

<input type="hidden" name="session_count" value="0">

<input type="submit" value="Login / Proceed">

</form>

</body>

</html>

[Link]

package [Link];

import [Link].*; import [Link].*; import [Link].*;

public class LibraryServlet extends HttpServlet {

protected void doPost(HttpServletRequest req, HttpServletResponse res)

throws ServletException, IOException {

[Link]("text/html");

2
PrintWriter out = [Link]();

String user = [Link]("username");

int count = [Link]([Link]("session_count")) + 1;

[Link]("<html><body><h2>Welcome, " + user + "!</h2>");

[Link]("<p>You visited this page " + count + " time(s).</p>");

[Link]("<form action='Library' method='post'>");

[Link]("<input type='hidden' name='username' value='" + user + "'>");

[Link]("<input type='hidden' name='session_count' value='" + count + "'>");

[Link]("<input type='submit' value='Continue'></form></body></html>");

}}

[Link]

<web-app xmlns="[Link] version="4.0">

<servlet>

<servlet-name>LibraryServlet</servlet-name>

<servlet-class>[Link]</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>LibraryServlet</servlet-name>

<url-pattern>/Library</url-pattern>

</servlet-mapping>

</web-app>

[Link]

[Link]

<%@ page import="[Link].*" %>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>University Exam Results</title>

<style>

body { font-family: Arial; margin: 20px; }

table { border-collapse: collapse; width: 60%; }

th, td { border: 1px solid #aaa; padding: 8px; text-align: left; }

3
th { background: #f2f2f2; color: #333; }

</style>

</head>

<body>

<h2>Online Examination - Student Mark List</h2>

<table>

<tr>

<th>ID</th><th>Name</th><th>Sub 1</th><th>Sub 2</th><th>Total</th>

</tr>

<%

String url = "jdbc:mysql://localhost:3306/universitydb";

String user = "root", pass = "root";

try {

[Link]("[Link]");

Connection con = [Link](url, user, pass);

Statement st = [Link]();

ResultSet rs = [Link]("SELECT * FROM students ORDER BY total_marks DESC");

while ([Link]()) {

%>

<tr>

<td><%= [Link](1) %></td>

<td><%= [Link](2) %></td>

<td><%= [Link](3) %></td>

<td><%= [Link](4) %></td>

<td><%= [Link](5) %></td>

</tr>

<%

[Link]();

} catch (Exception e) {

[Link]("<tr><td colspan='5'>Error: " + [Link]() + "</td></tr>");

%>

4
</table>

</body>

</html>

Sql commands

-- Create the database

CREATE DATABASE universitydb;

-- Use the database

USE universitydb;

-- Create the table

CREATE TABLE students (

student_id VARCHAR(10) PRIMARY KEY,

student_name VARCHAR(100) NOT NULL,

subject1_marks INT,

subject2_marks INT,

total_marks INT

);

-- Insert sample data

INSERT INTO students (student_id, student_name, subject1_marks, subject2_marks, total_marks) VALUES

('S1001', 'Alice Johnson', 85, 92, 177),('S1002', 'Bob Williams', 78, 88, 166),('S1003', 'Charlie Brown', 95, 80, 175),

('S1004', 'David Miller', 70, 75, 145),('S1005', 'Emma Davis', 90, 93, 183);

SELECT * FROM students;

Connection :

String url="jdbc:mysql://localhost:3306/universitydb";

String user="root";

String pass="root";

4. India map

[Link]

<!DOCTYPE html>

<html>

<head>

<title>Hotspot Creation</title>
5
<meta charset="UTF 8">

<meta name="viewport" content="width=devide-width,initial-scale=1.0">

</head>

<body>

<h2 align="center">Click on the map to know about places</h2>

<img src="[Link]" alt="India map" usemap="#places">

<map name="places">

<area shape="'rect" coords="329,965,389,989" title="Tamil Nadu" alt="Tamil Nadu"


href="[Link]">

<area shape="'rect" coords="333,325,415,351" title="Delhi" alt="Delhi" href="[Link]">

<area shape="'rect" coords="645,547,719,593"itle="Calcutta" alt="Calcutta" href="[Link]">

</map>

</body>

</html>

[Link]

<!DOCTYPE html>

<html>

<head>

<title>Tamil Nadu</title>

</head>

<body bgcolor="skyblue">

<font face="Times New Roman" size="5" color="Black">

<center>

<h2>Chennai is the capital of TamilNadu</h2>

<p>Many IT companies are located in chennai</p>

</center>

<br>

<a href="[Link]">Home</a>

</font>

</body>

</html>

[Link]

<!DOCTYPE html>

6
<html>

<head>

<title>Delhi</title>

</head>

<body bgcolor="skyblue">

<font face="Arial" size="5" color="Black">

<center>

<h2>Delhi is the capital of India</h2>

<p>Many IT companies are located in Delhi</p>

</center>

<br>

<a href="[Link]">Home</a>

</font>

</body>

</html>

[Link]

<!DOCTYPE html>

<html>

<head>

<title>Calcutta</title>

</head>

<body bgcolor="skyblue">

<font face="Times New Roman" size="5" color="Black">

<center>

<h2>Calcutta is the capital of West Bengal</h2>

<p>It is a wealthy city and is famous for the Sundarban Forests</p>

</center>

<br>

<a href="[Link]">Home</a>

</font>

</body>

</html>

5. Online banking application

7
[Link]

<!DOCTYPE html><html>

<head>

<title>Bank Validation</title>

<style>

body { font-family: sans-serif; margin: 10px; }

div { border: 1px solid #ccc; padding: 10px; margin-bottom: 15px; }

label { display: block; margin-top: 5px; }

</style>

</head>

<body>

<div><h2> Register</h2>

<form onsubmit="return validateRegistration()">

<label>User (6+): <input id="regUsername" required></label>

<label>Pass (8+, U, D): <input type="password" id="regPassword" required></label>

<label>Email: <input type="email" id="regEmail" required></label>

<input type="submit" value="Register">

</form>

</div>

<div><h2> Login</h2>

<form onsubmit="return validateLogin()">

<label>User: <input id="loginUsername" required></label>

<label>Pass: <input type="password" id="loginPassword" required></label>

<input type="submit" value="Login">

</form>

</div>

<div><h2> Profile</h2>

<form onsubmit="return validateProfile()">

<label>Phone (10D): <input id="profilePhone" required></label>

<label>PIN (4D): <input type="password" id="profilePin" required></label>

<input type="submit" value="Update profile">

</form>

</div>
8
<script>

// 1. Registration: 6+ user, 8+ pass (1 upper, 1 digit), valid email

function validateRegistration() {

const user = [Link]('regUsername').value,

pass = [Link]('regPassword').value,

email = [Link]('regEmail').value;

let errors = [];

if ([Link] < 6) [Link]("User must be 6+ chars.");

if (!/^(?=.[A-Z])(?=.\d).{8,}$/.test(pass)) [Link]("Pass needs 8+, upper, digit.");

if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) [Link]("Invalid email.");

if ([Link] > 0) {

alert("Reg Failed:\n" + [Link]('\n'));

return false;

alert(" registration Success! (Blocked)");

return false;

// 2. Login: Not empty

function validateLogin() {

const user = [Link]('loginUsername').value,

pass = [Link]('loginPassword').value;

if ([Link]() === "" || [Link]() === "") {

alert("Login Failed: Fields empty.");

return false;

alert("Login validated. (Blocked)");

return false;

// 3. Profile: Phone (10 digits), PIN (4 digits)

function validateProfile() {

const phone = [Link]('profilePhone').value,

pin = [Link]('profilePin').value;

let errors = [];

9
if (!/^\d{10}$/.test(phone)) [Link]("Phone must be 10 digits.");

if (!/^\d{4}$/.test(pin)) [Link]("PIN must be 4 digits.");

if ([Link] > 0) {

alert("Profile Failed:\n" + [Link]('\n'));

return false;

alert("Profile validated. (Blocked)");

return false;

</script></body></html>

[Link]:

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Minimal Catalog</title>

<style>

body { font-family: sans-serif; margin: 15px; }

header { background-color: #eee; padding: 10px; text-align: center; }

.product-card {

border: 1px solid #ccc;

padding: 10px;

margin: 10px;

display: inline-block; /* Minimal layout */

width: 30%; /* Three cards per row (approx) */

#featured-product {

border: 2px solid red;

background-color: #ffdddd;

display: block; /* Takes full width */

width: auto;

</style>

10
</head>

<body>

<header>

<h1> Minimal Product Catalog</h1>

</header>

<div id="featured-product" class="product-card">

<h2> Featured Deal!</h2>

<p>4K Smart TV.</p>

</div>

<div class="product-card">

<h3>Headphones</h3>

<p>Department: Electronics</p>

<p style="color: green; font-weight: bold;">Price: $199</p>

</div>

<div class="product-card">

<h3>Coffee Maker</h3>

<p>Department: Home Goods</p>

<p style="color: green; font-weight: bold;">Price: $79</p>

</div>

<div class="product-card">

<h3>Fitness Watch</h3>

<p>Department: Health</p>

<p style="color: green; font-weight: bold;">Price: $45</p>

</div>

<footer>

<p style="margin-top: 20px;">© 2025 Catalog.</p>

</footer>

</body>

</html>

7. Tomcat and University

[Link]

<!DOCTYPE html>

<html>
11
<head><title>Student Login</title></head>

<body>

<h2>Student Login</h2>

<form action="Login" method="post">

ID: <input type="text" name="studentId" required><br><br>

Pass: <input type="password" name="password" required><br><br>

<input type="submit" value="Login">

</form>

</body>

</html>

[Link]

package [Link];

import [Link];

import [Link].*;

import [Link];

public class LoginServlet extends HttpServlet {

private boolean validateCredentials(String studentId, String password) {

return "123".equals(password) && studentId != null && ![Link]();

protected void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

String studentId = [Link]("studentId");

String password = [Link]("password");

if (validateCredentials(studentId, password)) {

// Create and add Cookie (Session tracking)

Cookie studentCookie = new Cookie("student_id", studentId);

[Link](60 * 30); // 30 minutes

[Link](studentCookie);

[Link]("[Link]"); // Redirect to content

} else {

[Link]("[Link]?error=invalid"); // Redirect back

12
}

[Link]

<%@ page language="java" contentType="text/html; charset=UTF-8" %>

<%

String studentId = null;

Cookie[] cookies = [Link]();

if (cookies != null) {

for (Cookie cookie : cookies) {

if ([Link]().equals("student_id")) {

studentId = [Link]();

break;

if (studentId == null) {

[Link]("[Link]");

return;

String curriculum = "CS, MA, PH";

String examSchedule = "CS: 25-Nov, MA: 27-Nov";

String results = "CS: A, MA: B+";

%>

<!DOCTYPE html>

<html>

<head><title>Dashboard</title></head>

<body>

<a href="Logout">Logout</a>

<h1>Welcome, <%= studentId %></h1>

<h3>Curriculum</h3><p><%= curriculum %></p>

<h3>Schedule</h3><p><%= examSchedule %></p>

<h3>Results</h3><p><%= results %></p>

13
</body>

</html>

[Link]

package [Link];

import [Link];

import [Link].*;

import [Link];

public class LogoutServlet extends HttpServlet {

protected void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

Cookie studentCookie = new Cookie("student_id", "");

[Link](0);

[Link](studentCookie);

[Link]("[Link]?msg=loggedout");

[Link]

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="4.0" xmlns="[Link]

<servlet><servlet-name>LoginServlet</servlet-name><servlet-class>[Link]</servlet-
class></servlet>

<servlet-mapping><servlet-name>LoginServlet</servlet-name><url-pattern>/Login</url-pattern></servlet-
mapping>

<servlet><servlet-name>LogoutServlet</servlet-name><servlet-
class>[Link]</servlet-class></servlet>

<servlet-mapping><servlet-name>LogoutServlet</servlet-name><url-pattern>/Logout</url-
pattern></servlet-mapping>

</web-app>

8. Airway

Database

CREATE DATABASE airwaydb;

USE airwaydb;

CREATE TABLE flights (

14
flight_number VARCHAR(10) PRIMARY KEY,

origin VARCHAR(50),

destination VARCHAR(50),

available_seats INT,

fare DECIMAL(10, 2)

);

INSERT INTO flights VALUES

('AI101', 'DELHI', 'MUMBAI', 50, 4500.00),

('6E505', 'MUMBAI', 'BANGALORE', 12, 3200.50),

('UK707', 'KOLKATA', 'MUMBAI', 0, 6150.00);

[Link]

<%@ page import="[Link].*" %>

<html><body>

<h2>Flight Search</h2>

<%

String origin = [Link]("origin");

String destination = [Link]("destination");

%>

<form action="[Link]" method="get">

From: <input type="text" name="origin" required value="<%= origin != null ? origin : "" %>">

To: <input type="text" name="destination" required value="<%= destination != null ? destination : "" %>">

<input type="submit" value="Search">

</form>

<% if (origin != null && ![Link]()) {

final String DRIVER = "[Link]";

final String URL = "jdbc:mysql://localhost:3306/airwaydb";

final String USER = "user"; // <--- CHANGE THIS

final String PASS = "password"; // <--- CHANGE THIS

Connection con = null; PreparedStatement ps = null; ResultSet rs = null;

try {

[Link](DRIVER);

con = [Link](URL, USER, PASS);

15
String sql = "SELECT flight_number, fare, available_seats FROM flights WHERE origin = ? AND destination
= ?";

ps = [Link](sql);

[Link](1, [Link]());

[Link](2, [Link]());

rs = [Link]();

%>

<h3>Results:</h3>

<table border="1">

<tr><th>Flight No.</th><th>Fare (₹)</th><th>Availability</th></tr>

<%

boolean found = false;

while ([Link]()) {

found = true;

int seats = [Link]("available_seats");

%>

<tr>

<td><%= [Link]("flight_number") %></td>

<td><%= [Link]("fare") %></td>

<td><%= seats > 0 ? seats + " Available" : "Booked Out" %></td>

</tr>

<% }

if (!found) { %> <tr><td colspan='3'>No flights found.</td></tr> <% } %>

</table>

<%

} catch (Exception e) {

[Link]("<p style='color:red;'>DB ERROR.</p>");

} finally {

try { if (con != null) [Link](); } catch (Exception e) {}

} %>

</body>

16
</html>

9. Tourist places

[Link]

<?xml version="1.0" encoding="UTF-8"?>

<touristData>

<place name="TAJ MAHAL"><city>Agra</city><state>UP</state><desc>Mausoleum.</desc></place>

<place name="RED FORT"><city>Delhi</city><state>Delhi</state><desc>Fort.</desc></place>

<place name="GOLDEN
TEMPLE"><city>Amritsar</city><state>Punjab</state><desc>Gurdwara.</desc></place>

</touristData>

[Link]

<%@ page import="[Link], [Link]., [Link]., [Link]" %>

<html><body>

<h2>XML Place Finder</h2>

<% String search = [Link]("placeName"); %>

<form action="xml_finder.jsp" method="get">

Name: <input type="text" name="placeName" required value="<%= search != null ? search : "" %>">

<input type="submit" value="Search">

</form>

<% if (search != null && ![Link]()) {

String normSearch = [Link]().toUpperCase([Link]);

boolean found = false;

try {

String path = [Link]("tourist_places.xml");

File xmlFile = new File(path);

DocumentBuilderFactory factory = [Link]();

DocumentBuilder builder = [Link]();

Document doc = [Link](xmlFile);

NodeList nList = [Link]("place");

for (int i = 0; i < [Link](); i++) {

Element e = (Element) [Link](i);

String placeName = [Link]("name");

if ([Link](normSearch)) {

17
found = true;

String city = [Link]("city").item(0).getTextContent();

String state = [Link]("state").item(0).getTextContent();

String desc = [Link]("desc").item(0).getTextContent();

%>

<hr>

<b>Found: <%= placeName %></b><br>

City: <%= city %><br>

State: <%= state %><br>

Desc: <%= desc %><br>

<%

break;

if (!found) { [Link]("<p style='color:red;'>Place not found.</p>"); }

} catch (Exception e) {

[Link]("<p style='color:red;'>ERROR: XML file missing or malformed.</p>");

} %>

</body></html>

11th :Online supermarket

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Online Supermarket</title>

<script>

function
show(id){[Link](".page").forEach(p=>[Link]="none");[Link](i
d).[Link]="block";}

function validateForm(f){for(let e of [Link]("input[required]"))if(![Link])return alert("Please fill all


fields"),false;alert("Form submitted!");show('confirm');return false;}

</script>

18
<style>body{font-family:Arial;text-align:center}form{margin:20px
auto;width:250px}input,select{width:100%;margin:5px 0}</style>

</head>

<body onload="show('home')">

<h2>Online Supermarket</h2>

<nav><button onclick="show('home')">Home</button><button
onclick="show('reg')">Register</button><button onclick="show('login')">Login</button><button
onclick="show('groceries')">Groceries</button><button onclick="show('pay')">Payment</button></nav>

<div id="home" class="page"><h3>Welcome to FreshMart!</h3><p>Your one-stop online grocery


store.</p></div>

<div id="reg" class="page" style="display:none">

<h3>Registration</h3>

<form onsubmit="return validateForm(this)">

<input placeholder="Name" required><input placeholder="Email" required><input type="password"


placeholder="Password" required><button>Register</button>

</form></div>

<div id="login" class="page" style="display:none">

<h3>User Login</h3>

<form onsubmit="return validateForm(this)">

<input placeholder="Email" required><input type="password" placeholder="Password"


required><button>Login</button>

</form></div>

<div id="groceries" class="page" style="display:none">

<h3>Groceries List</h3>

<form onsubmit="return validateForm(this)">

<select required><option value="">Select


Item</option><option>Rice</option><option>Milk</option><option>Fruits</option></select>

<input type="number" placeholder="Quantity" required><button>Order</button>

</form></div>

<div id="pay" class="page" style="display:none">

<h3>Online Payment</h3>

<form onsubmit="return validateForm(this)">

<input placeholder="Card Number" required><input placeholder="Expiry Date" required><input


placeholder="CVV" required><button>Pay</button>

</form></div>

19
<div id="confirm" class="page" style="display:none"><h3>Order Confirmed!</h3><p>Thank you for shopping
with us.</p></div>

</body>

</html>

[Link]

Db

CREATE DATABASE payroll_db;

USE payroll_db;

CREATE TABLE employees (

employee_id VARCHAR(10) PRIMARY KEY,

employee_name VARCHAR(100),

designation VARCHAR(50),

basic_salary DECIMAL(10, 2),

hra DECIMAL(10, 2),

total_salary DECIMAL(10, 2)

);

INSERT INTO employees VALUES

('E101', 'Anand Varma', 'Engineer', 50000.00, 10000.00, 60000.00),

('E102', 'Priya Singh', 'Manager', 75000.00, 15000.00, 90000.00);

[Link]

<%@ page import="[Link].*" %>

<html><body>

<h2>Employee Payroll</h2>

<table border="1">

<tr>

<th>ID</th><th>Name</th><th>Designation</th><th>Basic</th><th>Total</th>

</tr>

<%

final String DRIVER = "[Link]";

final String URL = "jdbc:mysql://localhost:3306/payroll_db";

final String USER = "user";

final String PASS = "password";

Connection con = null; Statement stmt = null; ResultSet rs = null;

20
try {

[Link](DRIVER);

con = [Link](URL, USER, PASS);

String sql = "SELECT employee_id, employee_name, designation, basic_salary, total_salary FROM


employees";

stmt = [Link]();

rs = [Link](sql);

while ([Link]()) {

%>

<tr>

<td><%= [Link]("employee_id") %></td>

<td><%= [Link]("employee_name") %></td>

<td><%= [Link]("designation") %></td>

<td><%= [Link]("basic_salary") %></td>

<td><%= [Link]("total_salary") %></td>

</tr>

<%

} catch (Exception e) {

[Link]("<tr><td colspan='5' style='color:red;'>DB ERROR: Check connection.</td></tr>");

} finally {

try { if (con != null) [Link](); } catch (Exception e) {}

%>

</table></body></html>

13) Organic/agri

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Organic Stores Info</title>

<script>

const xmlData=`<stores>

21
<store><name>Green Farm</name><address>Main
Street</address><city>Hometown</city><products>Vegetables, Fruits</products></store>

<store><name>Organic Hub</name><address>Market
Road</address><city>Hometown</city><products>Grains, Dairy</products></store>

<store><name>Nature's Basket</name><address>Central
Plaza</address><city>Hometown</city><products>Fruits, Nuts</products></store>

<store><name>Fresh Pick</name><address>River
Lane</address><city>Hometown</city><products>Vegetables, Herbs</products></store>

<store><name>Agro Mart</name><address>Hill Street</address><city>Hometown</city><products>Organic


Seeds, Oils</products></store>

</stores>`;

function showDetails(){

const s=[Link]('sname').[Link]().toLowerCase();

const xml=new DOMParser().parseFromString(xmlData,"text/xml");

const stores=[Link]("store");

for(let st of stores){

if([Link]("name")[0].[Link]()===s){

[Link]("result").innerHTML=

`<b>${[Link]("name")[0].textContent}</b><br>

Address: ${[Link]("address")[0].textContent}<br>

City: ${[Link]("city")[0].textContent}<br>

Products: ${[Link]("products")[0].textContent}`;

return;

[Link]("result").innerHTML="";

</script>

</head>

<body>

<h3>Search Organic Store</h3>

<input id="sname" placeholder="Enter store name">

<button onclick="showDetails()">Search</button>

<div id="result"></div>

</body>
22
</html>

14. Taxi

Db

CREATE DATABASE taxi_db;

USE taxi_db;

CREATE TABLE taxis (

vehicle_no VARCHAR(15) PRIMARY KEY,

driver_name VARCHAR(100),

availability BOOLEAN,

distance_km DECIMAL(5, 2),

fare_rate_per_km DECIMAL(5, 2)

);

INSERT INTO taxis VALUES

('TN01AB1234', 'Vimal Kumar', TRUE, 2.50, 15.00),

('TN02CD5678', 'Suresh Babu', FALSE, 0.00, 15.00),

('TN03EF9012', 'Arjun Singh', TRUE, 6.80, 18.00);

[Link]

<%@ page import="[Link].*" %>

<html><body>

<h2>Live Taxi Status</h2>

<table border="1">

<tr>

<th>Status</th>

<th>Vehicle No.</th>

<th>Driver</th>

<th>Distance (KM)</th>

<th>Fare Rate (₹/KM)</th>

<th>Est. Fare (10 KM)</th>

</tr>

<%

final String DRIVER = "[Link]";

final String URL = "jdbc:mysql://localhost:3306/taxi_db";

final String USER = "user"; // <--- CHANGE THIS

23
final String PASS = "password"; // <--- CHANGE THIS

Connection con = null; Statement stmt = null; ResultSet rs = null;

try {

[Link](DRIVER);

con = [Link](URL, USER, PASS);

String sql = "SELECT * FROM taxis ORDER BY availability DESC";

stmt = [Link]();

rs = [Link](sql);

while ([Link]()) {

boolean available = [Link]("availability");

double fareRate = [Link]("fare_rate_per_km");

String statusText = available ? "Available" : "On-Trip";

double estimatedFare = fareRate * 10;

%>

<tr>

<td style="color: <%= available ? "green" : "red" %>;"><%= statusText %></td>

<td><%= [Link]("vehicle_no") %></td>

<td><%= [Link]("driver_name") %></td>

<td><%= [Link]("distance_km") %></td>

<td><%= fareRate %></td>

<td>₹ <%= [Link]("%.2f", estimatedFare) %></td>

</tr>

<%

} // End loop

} catch (Exception e) {

[Link]("<tr><td colspan='6' style='color:red;'>DB ERROR: Check connection.</td></tr>");

} finally {

try { if (con != null) [Link](); } catch (Exception e) {}

%>

</table>

</body></html>

24
[Link] details in library

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>E-Book Library</title>

<script>

const xmlData=`<library>

<book><title>Learn JavaScript</title><author>John
Doe</author><genre>Programming</genre><year>2021</year></book>

<book><title>HTML Basics</title><author>Jane Smith</author><genre>Web


Design</genre><year>2020</year></book>

<book><title>CSS Mastery</title><author>Robert Brown</author><genre>Web


Design</genre><year>2019</year></book>

<book><title>Python Essentials</title><author>Emily
Clark</author><genre>Programming</genre><year>2022</year></book>

<book><title>Data Science 101</title><author>Michael Lee</author><genre>Data


Science</genre><year>2023</year></book>

</library>`;

function showDetails(){

const name=[Link]('bname').[Link]().toLowerCase();

const xml=new DOMParser().parseFromString(xmlData,"text/xml");

const books=[Link]("book");

for(let b of books){

if([Link]("title")[0].[Link]()===name){

[Link]("result").innerHTML=

`<b>${[Link]("title")[0].textContent}</b><br>

Author: ${[Link]("author")[0].textContent}<br>

Genre: ${[Link]("genre")[0].textContent}<br>

Year: ${[Link]("year")[0].textContent}`;

return;

[Link]("result").innerHTML="";

}
25
</script>

</head>

<body>

<h3>Search E-Book</h3>

<input id="bname" placeholder="Enter book title">

<button onclick="showDetails()">Search</button>

<div id="result"></div>

</body>

</html>

26

You might also like