0% found this document useful (0 votes)
10 views13 pages

Ad. Java Mini Project-2 Report

The Mini-Project Report details the development of a User Management System using JSP and Servlets, aimed at managing user data through basic CRUD operations. The project includes a user-friendly interface for adding and viewing users, and demonstrates successful implementation of dynamic web technologies. The conclusion highlights the system's effectiveness in user management and its potential for future enhancements.
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)
10 views13 pages

Ad. Java Mini Project-2 Report

The Mini-Project Report details the development of a User Management System using JSP and Servlets, aimed at managing user data through basic CRUD operations. The project includes a user-friendly interface for adding and viewing users, and demonstrates successful implementation of dynamic web technologies. The conclusion highlights the system's effectiveness in user management and its potential for future enhancements.
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

Mini-Project Report

On
“User Management System”

Submitted for the partial fulfilment of Fifth Semester subject “Advance Java”

Course code: CM302G$

Submitted by: -
Harshdeep Kaur Bamrah- 2213004

Under the Guidance of

Mr. S. A. Khatri
Lecturer Department of Computer Engineering

ODD-2024

Department of Computer Engineering

Government Polytechnic, Nagpur

(An Autonomous Institute of Government of Maharashtra)

1
Certificate

This is certified that the Mini Project titled

“User Management System”


Carried out under guidance of

Mr. S. A. Khatri

Department of Computer Engineering

Submitted by:

Harshdeep Kaur Bamrah- 2213004

As the partial fulfilment of Fifth Semester subject “ADVANCE JAVA” Course code

CM302G$ during the term ODD-24

Mr. S. A. Khatri Dr. M. V Sarode

Guide and Lecturer Head of Department

Department of Computer Engineering Department of Computer Engineering

ODD-24

Department of Computer Engineering

Government Polytechnic, Nagpur

(An Autonomous Institute of Government of Maharashtra)


2
INDEX

Sr. no. Topic Page no.

1. Acknowledgment 4

2. Introduction to Topic 5

3. Program 6

4. Output 12

3
ACKNOWLEGEMENT
We would like to place on record our deep sense of gratitude to our guide, Mr.
S. A. Khatri Department of Computer Engineering for his generous guidance, helpful
and useful suggestions, continuous encouragement and supervision throughout the
course of present work.

We express our sincere gratitude to Dr. M. V SARODE, Head of Department of


Computer Engineering for his stimulating guidance. The success of any work depends
on efforts of many individuals. We would like to take this opportunity to express out
deep gratitude to all those who extended their support and have guided us to complete
this project work.

We are extremely thankful to Dr. R. P MOGRE, Principal for providing us


infrastructural facilities work in, without which this work would not have been possible.

4
INTRODUCTION

The User Management System is a web-based application developed using JSP


(JavaServer Pages) and Servlets. This application demonstrates basic CRUD (Create, Read,
Update, Delete) operations for managing user data in a structured and efficient manner.
Objectives of the Project:
1. User-Friendly Interface: Provide a simple and clean UI for adding, viewing, and
managing user data.
2. Data Storage and Retrieval: Facilitate data entry and display using dynamic web
technologies.
3. Real-Time Updates: Allow users to interact with and manage data seamlessly
through web forms.
Features:
1. Add New Users:
Users can enter details like their name, email, and country into a form. Upon
submission, this data is processed and stored for further operations.
2. View All Users:
A table displays the list of all users. The data is fetched dynamically, making it easier
to manage and view records.
3. Navigation:
Buttons and links enable seamless transitions between pages, such as adding a new
user and viewing the list of users.

5
PROGRAM:

UserServlet.java

import jakarta.servlet.*;
import jakarta.servlet.http.*;
import com.example.User;
import java.io.IOException;
import java.util.*;

@WebServlet("/Userservlet")
public class Userservlet extends HttpServlet {

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws


ServletException, IOException {

String name = request.getParameter("name");


String email = request.getParameter("email");
String country = request.getParameter("country");

// Creating a new User object


User newUser = new User(name, email, country);

// Retrieving existing users from session (if any)


HttpSession session = request.getSession(); // Create or get current session
List<User> users = (List<User>) session.getAttribute("users");

// If no users exist, initialize a new list


if (users == null) {
users = new ArrayList<>();
}

users.add(newUser);
session.setAttribute("users", users);
request.setAttribute("message", "User saved successfully!");

// Forward the request to index.jsp to display the success message


RequestDispatcher dispatcher = request.getRequestDispatcher("index.jsp");
dispatcher.forward(request, response);
}
}

User.java

package com.example;
public class User {
private String name;
private String email;
private String country;

public User(String name, String email, String country) {

6
this.name = name;
this.email = email;
this.country = country;
}

public String getName() {


return name;
}

public String getEmail() {


return email;
}

public String getCountry() {


return country;
}
}

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-


8859-1"%>
<html>
<head>
<title>User Management</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f9;
margin: 0;
padding: 0;
}

h2 {
text-align: center;
color: #333;
}

.container {
width: 50%;
margin: 50px auto;
background-color: #fff;
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.form-group {
margin-bottom: 20px;
}

label {
font-size: 18px;

7
color: #333;
display: block;
margin-bottom: 5px;
}

input[type="text"], input[type="email"], input[type="submit"] {


width: 100%;
padding: 10px;
margin: 5px 0;
border: 2px solid #ddd;
border-radius: 5px;
box-sizing: border-box;
}

input[type="submit"] {
background-color: #4CAF50;
color: white;
cursor: pointer;
border: none;
}

input[type="submit"]:hover {
background-color: #45a049;
}

.back-link {
text-align: center;
margin-top: 20px;
}

.back-link button {
background-color: #4CAF50;
color: white;
border: none;
padding: 10px 20px;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
width: 100%;
}

.back-link button:hover {
background-color: #45a049;
}

.message {
color: green;
text-align: center;
font-size: 18px;
}
</style>
</head>
<body>

<h2>User Management</h2>

8
<div class="container">
<h3>Add New User</h3>
<form action="Userservlet" method="post">
<div class="form-group">
<label for="name">User Name:</label>
<input type="text" name="name" id="name" required />
</div>

<div class="form-group">
<label for="email">User Email:</label>
<input type="email" name="email" id="email" required />
</div>

<div class="form-group">
<label for="country">Country:</label>
<input type="text" name="country" id="country" required />
</div>

<div class="form-group">
<input type="submit" value="Save" />
</div>
</form>

<%
// Retrieve message attribute (if any) and display
String message = (String) request.getAttribute("message");
if (message != null) {
out.println("<p class='message'>" + message + "</p>");
}
%>

<!-- Button to navigate to the next page -->


<div class="back-link">
<form action="listUsers.jsp">
<button type="submit">Display All Users</button>
</form>
</div>
</div>

</body>
</html>

listUsers.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-


8859-1"%>
<%@ page import="java.util.List" %>
<%@ page import="com.example.User" %>
<html>
<head>
<title>All Users</title>
<style>

9
table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
}

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

th {
background-color: #4CAF50; /* Green background for header */
color: white; /* White text color for header */
}

tr:nth-child(even) {
background-color: #f2f2f2; /* Light gray for even rows */
}

tr:nth-child(odd) {
background-color: #ffffff; /* White for odd rows */
}

tr:hover {
background-color: #ddd; /* Light gray when hovering over a row */
}

.message {
color: #5cb85c;
font-weight: bold;
}
</style>
</head>
<body>

<h2>List of All Users</h2>

<%
// Retrieve the list of users from session
List<User> users = (List<User>) session.getAttribute("users");

if (users != null && !users.isEmpty()) {


%>
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th>Country</th>
</tr>
<%
for (User user : users) {
%>
<tr>

10
<td><%= user.getName() %></td>
<td><%= user.getEmail() %></td>
<td><%= user.getCountry() %></td>
</tr>
<%
}
%>
</table>
<%
} else {
%>
<p>No users found.</p>
<%
}
%>

<a href="index.jsp">Back to Add New User</a>

</body>
</html>

11
OUTPUT

12
Conclusion:
The User Management System successfully provides a user-friendly platform for adding and
viewing user details. It processes data dynamically using JSP and Servlets, displays user
feedback, and ensures smooth navigation. The system effectively handles user management
tasks and is scalable for future enhancements.

Result:
Hence, we have successfully implemented a User Management System in Java.The project
demonstrates the practical implementation of JSP and Servlets for building dynamic web
applications, achieving its objectives of efficient user management with scope for further
development.

13

You might also like