Skip to content

Abushahma736/Advanced-Java-Projects

Repository files navigation

Advanced Java Projects

This repository contains several Java web applications demonstrating servlet programming and database connectivity.

🚀 Projects Included

  1. AddTwoServletINOnePackage - Two servlets in one package demonstrating basic servlet functionality
  2. ArithmeticWebApp - Web application for arithmetic operations (addition, subtraction, multiplication, division)
  3. ServletDemo - Basic servlet demonstration with GET/POST request handling
  4. SessionManagement - Session management with login/logout functionality
  5. InsertTableDemo - MySQL database connectivity demonstration

📋 Prerequisites

  • Java 11 or higher
  • Maven 3.6 or higher
  • Apache Tomcat 10.x (for servlet projects)
  • MySQL Server (for InsertTableDemo project)

🛠️ Building the Projects

Using Maven (Recommended)

  1. Build all projects:

    mvn clean compile
  2. Build individual projects:

    cd AddTwoServletINOnePackage
    mvn clean compile
  3. Package WAR files:

    mvn clean package

🚀 Running the Projects

Servlet Projects

  1. Deploy the generated WAR files to your Tomcat server
  2. Access the applications through your browser:
    • http://localhost:8080/AddTwoServletINOnePackage/FirstServlet
    • http://localhost:8080/AddTwoServletINOnePackage/SecondServlet
    • http://localhost:8080/ArithmeticWebApp/
    • http://localhost:8080/ServletDemo/
    • http://localhost:8080/SessionManagement/

InsertTableDemo

  1. Set up MySQL database:

    CREATE DATABASE jdbc_db;
  2. Update database credentials in InsertDemo.java if needed:

    String url = "jdbc:mysql://localhost:3306/jdbc_db";
    String user = "root";
    String password = "your_password";
  3. Run the application:

    cd InsertTableDemo
    mvn exec:java

📁 Project Structure

AdvanceJavaProjects/
├── pom.xml                          # Parent POM with dependency management
├── AddTwoServletINOnePackage/
│   ├── pom.xml
│   └── src/main/java/com/example/
│       ├── FirstServlet.java
│       └── SecondServlet.java
├── ArithmeticWebApp/
│   ├── pom.xml
│   └── src/main/java/com/example/
│       └── ArithmeticServlet.java
├── ServletDemo/
│   ├── pom.xml
│   └── src/main/java/com/example/
│       └── MyServlet.java
├── SessionManagement/
│   ├── pom.xml
│   └── src/main/java/com/example/servlets/
│       ├── LoginServlet.java
│       ├── DashboardServlet.java
│       └── LogoutServlet.java
└── InsertTableDemo/
    ├── pom.xml
    └── src/main/java/com/example/
        └── InsertDemo.java

📦 Dependencies

  • Jakarta Servlet API 6.0.0 - For servlet projects
  • MySQL Connector/J 8.2.0 - For database connectivity

🔧 Features

AddTwoServletINOnePackage

  • Two servlets in one package
  • Basic HTTP GET request handling
  • HTML response generation

ArithmeticWebApp

  • Arithmetic operations (+, -, *, /)
  • Input validation
  • Error handling for division by zero
  • UTF-8 character support

ServletDemo

  • GET and POST request handling
  • Form data processing
  • Parameter extraction
  • HTML response generation

SessionManagement

  • User authentication
  • Session creation and management
  • Login/logout functionality
  • Dashboard with user information
  • Session invalidation

InsertTableDemo

  • MySQL database connectivity
  • JDBC connection management
  • Database connection testing

🐛 Troubleshooting

Common Issues

  1. "The import jakarta cannot be resolved"

    • Ensure Maven dependencies are downloaded: mvn dependency:resolve
    • Check that your IDE is configured to use Maven
  2. "MySQL connector not found"

    • Verify MySQL server is running
    • Check database credentials in InsertDemo.java
    • Ensure MySQL Connector JAR is in classpath
  3. Servlet not found errors

    • Verify web.xml configuration
    • Check servlet mapping URLs
    • Ensure WAR file is properly deployed

📝 Notes

  • All servlet projects use Jakarta EE 6.0.0 (the modern replacement for Java EE)
  • Projects are configured for Java 11
  • WAR files are generated with failOnMissingWebXml=false for convenience
  • All projects include proper error handling and input validation

👨‍💻 Author

Abushahma736

📄 License

This project is open source and available under the MIT License.


Happy Coding! 🎉

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published