Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Java Web Application - User Login System

This is a web application developed using pure Java technology stack, implementing user login verification and personalized welcome page functionality. Here is the public link: https://54.221.107.40/webapp/login and demo video link: https://youtu.be/CzeJUOHXt2c

πŸš€ Technology Stack

  • Java 11
  • Maven - Project Management
  • Servlet 4.0 - Web Services
  • JSP 2.3 - Page Templates
  • JSTL 1.2 - Tag Library
  • MySQL 8.0+ - Database
  • Tomcat 9.0 - Application Server

πŸ“‹ Features

  • βœ… User Login Verification
  • βœ… User Registration System
  • βœ… Secure Password Hashing (BCrypt)
  • βœ… Password Strength Validation
  • βœ… Database User Management
  • βœ… Session Management
  • βœ… Personalized Welcome Page
  • βœ… Responsive UI Design
  • βœ… Error Handling
  • βœ… User Statistics

πŸ› οΈ Requirements

  1. Java 11 or higher
  2. Maven 3.6+
  3. MySQL 8.0+
  4. Tomcat 9.0+

πŸ“¦ Installation and Configuration

1. Database Configuration

  1. Start MySQL service
  2. Execute database initialization script:
    mysql -u root -p < database_init.sql
  3. Modify database connection configuration (if needed):
    • File: src/main/java/com/example/webapp/util/DatabaseUtil.java
    • Modify database URL, username and password

2. Project Build

# Clean and compile project
mvn clean compile

# Package as WAR file
mvn clean package

3. Deploy to Tomcat

  1. Copy the generated target/webapp.war file to Tomcat's webapps directory
  2. Start Tomcat server
  3. Access: http://localhost:8080/webapp

🎯 Usage Instructions

User Registration

  1. Access Registration Page: http://localhost:8080/webapp/register
  2. Fill Registration Form:
    • Username (unique)
    • Email address
    • Full name
    • Password (must contain uppercase, lowercase, and numbers)
    • Confirm password
  3. Submit Registration: System will hash password securely and create account

Test Accounts

Username Password Description
hostedftp Money123456789! Test1
admin Admin111111111@ Test2
user1 Password123456# Test3 (demo)

Note: All test accounts need to be registered first using the registration form.

Access Paths

  • Homepage: http://localhost:8080/webapp/
  • Registration Page: http://localhost:8080/webapp/register
  • Login Page: http://localhost:8080/webapp/login
  • Welcome Page: http://localhost:8080/webapp/welcome
  • Test Servlet: http://localhost:8080/webapp/hello

πŸ“ Project Structure

webapp/
β”œβ”€β”€ src/main/java/com/example/webapp/
β”‚   β”œβ”€β”€ model/
β”‚   β”‚   └── User.java                 # User Data Model
β”‚   β”œβ”€β”€ dao/
β”‚   β”‚   └── UserDAO.java              # User Data Access Object
β”‚   β”œβ”€β”€ util/
β”‚   β”‚   β”œβ”€β”€ DatabaseUtil.java         # Database Connection Utility
β”‚   β”‚   └── PasswordUtil.java         # Password Security Utility (BCrypt)
β”‚   β”œβ”€β”€ servlet/
β”‚   β”‚   β”œβ”€β”€ LoginServlet.java         # Login Processing
β”‚   β”‚   β”œβ”€β”€ RegisterServlet.java      # User Registration
β”‚   β”‚   β”œβ”€β”€ WelcomeServlet.java       # Welcome Page
β”‚   β”‚   └── LogoutServlet.java        # Logout Processing
β”‚   └── HelloServlet.java             # Example Servlet
β”œβ”€β”€ src/main/webapp/
β”‚   β”œβ”€β”€ WEB-INF/
β”‚   β”‚   └── web.xml                   # Web Configuration
β”‚   β”œβ”€β”€ index.jsp                     # Homepage
β”‚   β”œβ”€β”€ login.jsp                     # Login Page
β”‚   β”œβ”€β”€ register.jsp                  # Registration Page
β”‚   β”œβ”€β”€ welcome.jsp                   # Welcome Page
β”‚   └── error.jsp                     # Error Page
β”œβ”€β”€ database_init.sql                 # Database Initialization Script
β”œβ”€β”€ pom.xml                          # Maven Configuration
└── README.md                        # Project Documentation

πŸ”§ Configuration

Database Connection Configuration

Modify the following configuration in DatabaseUtil.java:

private static final String DB_URL = "jdbc:mysql://localhost:3306/webapp_db?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true";
private static final String DB_USERNAME = "root";
private static final String DB_PASSWORD = "root"; // Change to your MySQL password

Password Security Configuration

The application uses BCrypt for password hashing with the following configuration in PasswordUtil.java:

private static final int BCRYPT_ROUNDS = 12; // BCrypt strength level

Password Requirements:

  • Minimum 6 characters
  • Must contain uppercase letters
  • Must contain lowercase letters
  • Must contain numbers

Session Configuration

Configure session timeout in web.xml:

<session-config>
    <session-timeout>30</session-timeout> <!-- 30 minutes -->
</session-config>

πŸ› Troubleshooting

Common Issues

  1. Database Connection Failed

    • Check if MySQL service is running
    • Verify database connection configuration
    • Confirm database and tables are created
  2. Compilation Errors

    • Check if Java version is 11+
    • Run mvn clean compile to recompile
  3. Deployment Failed

    • Check Tomcat service status
    • Confirm WAR file integrity
    • Check Tomcat logs

Log Viewing

  • Application Logs: Check console output
  • Tomcat Logs: $TOMCAT_HOME/logs/
  • MySQL Logs: Check MySQL error logs

πŸ“ Development Notes

Security Features

Password Security:

  • All passwords are hashed using BCrypt algorithm
  • BCrypt rounds set to 12 for strong security
  • Passwords are never stored in plain text
  • Password strength validation on registration

User Registration:

  • Username uniqueness validation
  • Email format validation
  • Password confirmation matching
  • Secure password hashing before database storage

Adding New Features

  1. Create new classes in appropriate packages
  2. Update web.xml to configure new Servlet mappings
  3. Create corresponding JSP pages
  4. Test feature completeness

Database Extension

  1. Modify User model class
  2. Update SQL statements in UserDAO
  3. Execute database migration scripts

Security Best Practices

  1. Password Handling: Always use PasswordUtil for password operations
  2. Input Validation: Validate all user inputs on both client and server side
  3. SQL Injection: Use PreparedStatement for all database queries
  4. Session Management: Implement proper session timeout and invalidation

πŸ“„ License

This project is for learning and demonstration purposes only.

🀝 Contributing

Welcome to submit Issues and Pull Requests to improve this project!


πŸ”’ Security Implementation

This project now includes comprehensive security features:

  • βœ… Password Hashing: BCrypt algorithm with 12 rounds
  • βœ… Password Strength Validation: Enforces strong password requirements
  • βœ… SQL Injection Protection: All queries use PreparedStatement
  • βœ… Input Validation: Server-side validation for all user inputs
  • βœ… Session Security: Proper session management and timeout
  • βœ… User Registration: Secure account creation with validation

Note: This is a demonstration project with security features implemented. For production use, consider additional security measures such as HTTPS, rate limiting, and comprehensive logging.

About

Full stack project: Java Web Application with AWS EC2 RDS, MySQL, Tomcat, Nginx SSL (The web link below is currently unavailable, as I have taken it offline due to AWS hosting costs.)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages