Java Use Case
Java Use Case
PROBLEM STATEMENT
Validated Login for Employee management JSP: Company ABC planned to create a
website for maintaining employee details. Login page need to be designed with
username, password and captcha. Username is their mail-id and password should
contain at-least 1-Uppercase alphabet, 1-special character, 1- lower alphabet. Design
the page using front end and server scripting with client / server validation. Use the
technologies: HTML5, CSS5, JavaScript, JSP.
AIM: To design a secure login system for employee management using JSP, ensuring
user authentication with email and password complexity validation.
ALGORITHM:
1. **Frontend Design:**
1. Create an HTML file for the login page layout.
2. Include input fields for email, password, and captcha.
3. Add labels and placeholders for each input field.
4. Use CSS for styling the login form to enhance the user experience.
2. **Client-Side Validation:**
1. Write JavaScript functions to validate the email format.
2. Implement password complexity validation using regular expressions.
3. Ensure all required fields are filled before form submission.
4. Display appropriate error messages for invalid input.
6. **Security Measures:**
1. Implement encryption for password storage (if storing passwords).
2. Sanitize input data to prevent SQL injection and XSS attacks.
3. Implement measures to prevent brute force attacks (e.g., rate limiting,
CAPTCHA).
7. **Testing:**
1. Test the login system thoroughly with various scenarios.
2. Test positive cases (valid login), negative cases (invalid login), and edge cases
(empty fields, incorrect formats).
3. Ensure the system behaves as expected and handles errors appropriately.
8. **Deployment:**
1. Deploy the login system to a secure server environment.
2. Monitor the system for security vulnerabilities and performance issues.
3. Regularly update and maintain the system to address any security patches or
updates.
PROGRAM
login.jsp:
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="login-container">
<h2>Login</h2>
<form action="validateLogin.jsp" method="post" onsubmit="return validateForm()">
<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
</div>
<div class="form-group">
<label for="captcha">Captcha:</label>
<!-- Add your captcha code here -->
</div>
<button type="submit">Login</button>
</form>
</div>
<script src="script.js"></script>
</body>
</html>
validateLogin.jsp:
<%
// Dummy user credentials for demonstration
String validEmail = "[email protected]";
String validPassword = "Password@123";
script.js:
function validateForm() {
var password = document.getElementById("password").value;
style.css:
.login-container {
width: 300px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
}
.form-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"],
input[type="email"],
input[type="password"] {
width: 100%;
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
}
button {
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
RESULT: HENCE,THE PROGRAM To design a secure login system for
employee management using JSP, ensuring user authentication with email and
password complexity validation.