Advanced Java Programming
Mini -Project
[Link]
<%@ page import="[Link].*" %>
<html>
<head>
<title>Login</title>
<style>
body {
font-family: Arial;
background: linear-gradient(to right, #4facfe, #00f2fe);
}
.container {
width: 320px;
margin: auto;
margin-top: 120px;
padding: 25px;
background: white;
border-radius: 12px;
box-shadow: 0px 0px 15px rgba(0,0,0,0.2);
text-align: center;
}
h2 {
margin-bottom: 20px;
}
input {
width: 100%;
padding: 10px;
margin: 8px 0;
border-radius: 6px;
border: 1px solid #ccc;
}
button {
width: 100%;
padding: 10px;
background: #4facfe;
color: white;
border: none;
border-radius: 6px;
font-size: 16px;
}
button:hover {
background: #007bff;
}
a{
color: #007bff;
text-decoration: none;
}
</style>
</head>
<body>
<div class="container">
<h2> Doctor Login</h2>
<form method="post">
<input type="text" name="username" placeholder="Enter Username" required>
<input type="password" name="password" placeholder="Enter Password" required>
<button type="submit">Login</button>
</form>
<p>New user? <a href="[Link]">Register Here</a></p>
<%
String username = [Link]("username");
String password = [Link]("password");
if(username != null && password != null){
try {
[Link]("[Link]");
Connection con = [Link](
"jdbc:mysql://localhost:3306/javadoctor",
"root",
"root" // change if needed
);
PreparedStatement ps = [Link](
"SELECT * FROM users WHERE username=? AND password=?"
);
[Link](1, username);
[Link](2, password);
ResultSet rs = [Link]();
if([Link]()){
[Link]("user", username);
// ✅ UPDATED REDIRECT
[Link]("[Link]");
} else {
[Link]("<p style='color:red;'>❌ Invalid Login</p>");
[Link]();
} catch(Exception e){
[Link](e);
}
}
%>
</div>
</body>
</html>
[Link]
<%@ page import="[Link].*" %>
<html>
<head>
<title>Register</title>
<style>
body {
font-family: Arial;
background: linear-gradient(to right, #43e97b, #38f9d7);
}
.container {
width: 320px;
margin: auto;
margin-top: 120px;
padding: 25px;
background: white;
border-radius: 12px;
box-shadow: 0px 0px 15px rgba(0,0,0,0.2);
text-align: center;
}
input {
width: 100%;
padding: 10px;
margin: 8px 0;
border-radius: 6px;
border: 1px solid #ccc;
}
button {
width: 100%;
padding: 10px;
background: #28a745;
color: white;
border: none;
border-radius: 6px;
}
button:hover {
background: #218838;
}
</style>
</head>
<body>
<div class="container">
<h2>📝 Register</h2>
<form method="post">
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Register</button>
</form>
<p><a href="[Link]">Back to Login</a></p>
<%
String username = [Link]("username");
String password = [Link]("password");
if(username != null && password != null){
try {
[Link]("[Link]");
Connection con = [Link](
"jdbc:mysql://localhost:3306/javadoctor",
"root",
"root"
);
PreparedStatement ps = [Link](
"INSERT INTO users(username, password) VALUES (?, ?)"
);
[Link](1, username);
[Link](2, password);
int i = [Link]();
if(i > 0){
[Link]("<p style='color:green;'>✅ Registered Successfully</p>");
[Link]();
} catch(Exception e){
[Link](e);
}
}
%>
</div>
</body>
</html>
[Link]
<%
String user = (String) [Link]("user");
if(user == null){
[Link]("[Link]");
}
%>
<html>
<head>
<title>Doctor Dashboard</title>
<style>
body {
margin: 0;
font-family: Arial;
background: #f0f4f8;
}
/* Navbar */
.navbar {
background: #007bff;
padding: 15px 30px;
color: white;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 18px;
}
.logout {
color: white;
text-decoration: none;
font-weight: bold;
}
/* Layout */
.container {
padding: 30px;
}
/* Cards */
.card {
background: white;
padding: 20px;
border-radius: 12px;
box-shadow: 0px 4px 10px rgba(0,0,0,0.1);
margin-bottom: 20px;
}
/* Grid */
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
}
/* Stats */
.stat {
text-align: center;
font-size: 22px;
font-weight: bold;
}
/* List */
ul {
padding-left: 20px;
}
/* Profile */
.profile {
display: flex;
align-items: center;
}
.profile img {
width: 70px;
height: 70px;
border-radius: 50%;
margin-right: 15px;
}
</style>
</head>
<body>
<!-- NAVBAR -->
<div class="navbar">
<div> JavaDoctor Portal</div>
<div>
Welcome, Dr. <%= user %> |
<a class="logout" href="[Link]">Logout</a>
</div>
</div>
<div class="container">
<!-- PROFILE -->
<div class="card profile">
<img src="[Link]
<div>
<h3>Dr. <%= user %></h3>
<p>General Physician</p>
<p>Status: Active </p>
</div>
</div>
<!-- STATS -->
<div class="grid">
<div class="card">
<div class="stat">25</div>
<p>Patients Today</p>
</div>
<div class="card">
<div class="stat">12</div>
<p>Appointments</p>
</div>
<div class="card">
<div class="stat">5</div>
<p>Reports Pending</p>
</div>
</div>
<!-- APPOINTMENTS -->
<div class="card">
<h3> Today’s Appointments</h3>
<ul>
<li>10:00 AM - Virat Kholi</li>
<li>11:30 AM - Rajat Patidar</li>
<li>01:00 PM -Cristano Ronaldo </li>
</ul>
</div>
<!-- PATIENT RECORDS -->
<div class="card">
<h3>Patient Records</h3>
<ul>
<li>=Virat Kholi - Fever</li>
<li>Rajat Patidar - Diabetes</li>
<li>Cristano Ronaldo - Checkup</li>
</ul>
</div>
<!-- ABOUT -->
<div class="card">
<h3> About Project</h3>
<p>This project demonstrates a Doctor Portal using JSP, JDBC and MySQL.</p>
</div>
</div>
</body>
</html>
[Link]
<web-app xmlns="[Link]
version="3.1">
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
[Link]
<%
[Link]();
[Link]("[Link]");
%>
Output: