This repository contains several Java web applications demonstrating servlet programming and database connectivity.
- AddTwoServletINOnePackage - Two servlets in one package demonstrating basic servlet functionality
- ArithmeticWebApp - Web application for arithmetic operations (addition, subtraction, multiplication, division)
- ServletDemo - Basic servlet demonstration with GET/POST request handling
- SessionManagement - Session management with login/logout functionality
- InsertTableDemo - MySQL database connectivity demonstration
- Java 11 or higher
- Maven 3.6 or higher
- Apache Tomcat 10.x (for servlet projects)
- MySQL Server (for InsertTableDemo project)
-
Build all projects:
mvn clean compile
-
Build individual projects:
cd AddTwoServletINOnePackage mvn clean compile
-
Package WAR files:
mvn clean package
- Deploy the generated WAR files to your Tomcat server
- 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/
-
Set up MySQL database:
CREATE DATABASE jdbc_db;
-
Update database credentials in
InsertDemo.java
if needed:String url = "jdbc:mysql://localhost:3306/jdbc_db"; String user = "root"; String password = "your_password";
-
Run the application:
cd InsertTableDemo mvn exec:java
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
- Jakarta Servlet API 6.0.0 - For servlet projects
- MySQL Connector/J 8.2.0 - For database connectivity
- Two servlets in one package
- Basic HTTP GET request handling
- HTML response generation
- Arithmetic operations (+, -, *, /)
- Input validation
- Error handling for division by zero
- UTF-8 character support
- GET and POST request handling
- Form data processing
- Parameter extraction
- HTML response generation
- User authentication
- Session creation and management
- Login/logout functionality
- Dashboard with user information
- Session invalidation
- MySQL database connectivity
- JDBC connection management
- Database connection testing
-
"The import jakarta cannot be resolved"
- Ensure Maven dependencies are downloaded:
mvn dependency:resolve
- Check that your IDE is configured to use Maven
- Ensure Maven dependencies are downloaded:
-
"MySQL connector not found"
- Verify MySQL server is running
- Check database credentials in
InsertDemo.java
- Ensure MySQL Connector JAR is in classpath
-
Servlet not found errors
- Verify
web.xml
configuration - Check servlet mapping URLs
- Ensure WAR file is properly deployed
- Verify
- 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
Abushahma736
- GitHub: @Abushahma736
This project is open source and available under the MIT License.
Happy Coding! 🎉