A Java web application that implements a basic e-commerce shopping cart system with user and admin functionalities.
- User registration and authentication
- Browse available items
- Add items to shopping cart
- Modify cart quantities
- Remove items from cart
- Complete checkout process
- Secure admin login (ID: -1, Password: 1234)
- Manage inventory (add/remove/edit items)
- View and manage registered users
- Monitor item quantities
- Add new items to the system
- Edit item details (name, price)
- Java Servlets for handling HTTP requests
- JDBC for database operations
- MySQL database for data persistence
-
User
- uid (User ID)
- uname (Username)
- pass (Password)
-
Item
- itid (Item ID)
- itname (Item Name)
- quantity
- price
-
Cart
- cid (Cart ID)
- uid (User ID)
- itid (Item ID)
- itname (Item Name)
- price
- quantity
Userdao.java
: Handles user-related database operationsItemdao.java
: Manages item inventory operationsCartdao.java
: Handles shopping cart operations
-
Admin Controllers
AdminLogin.java
: Handles admin authenticationAdminAddItem.java
: Manages adding inventoryAdminEditItems.java
: Handles item modificationsAdminRemoveItem.java
: Manages inventory removal
-
User Controllers
UserLogin.java
: Handles user authenticationUserRegister.java
: Manages user registrationBuyItem.java
: Processes purchase transactionsRemoveItem.java
: Handles cart item removal
The application connects to MySQL database with the following configuration:
URL: "jdbc:mysql://localhost:3306/online_shopping"
Username: "root"
Password: "QWERTY"
-
Database Setup
- Install MySQL Server
- Create a database named
online_shopping
- Configure the database credentials in DAO classes if needed
-
Project Dependencies
- Java Development Kit (JDK)
- MySQL Connector/J
- Java Servlet API
- JSP Standard Tag Library (JSTL)
-
Deployment
- Deploy the application on a Java web server (e.g., Apache Tomcat)
- Ensure database connectivity
- Start the server and access the application
-
Admin Access
- Login with admin credentials (ID: -1, Password: 1234)
- Access admin dashboard at
admintask.jsp
- Manage inventory and users
-
User Access
- Register new account at
usereg.jsp
- Login at
userlogin.jsp
- Browse items at
shopitems.jsp
- View cart at
usercart.jsp
- Register new account at
- Session management for user authentication
- Password protection for user accounts
- Separate admin privileges
- Input validation for critical operations
The application includes comprehensive error handling for:
- Database connectivity issues
- Invalid login attempts
- Inventory management errors
- Cart operation failures
+---java
¦ +---demojstl
¦ +---bean
¦ ¦ Cart.java
¦ ¦ Item.java
¦ ¦ User.java
¦ ¦
¦ +---controller
¦ ¦ AdminAddItem.java
¦ ¦ AdminAddItems.java
¦ ¦ AdminEditItems.java
¦ ¦ AdminLogin.java
¦ ¦ AdminLogout.java
¦ ¦ AdminRemoveItem.java
¦ ¦ BuyItem.java
¦ ¦ Checkout.java
¦ ¦ RemoveItem.java
¦ ¦ RemoveUser.java
¦ ¦ UserLogin.java
¦ ¦ UserLogout.java
¦ ¦ UserRegister.java
¦ ¦
¦ +---dao
¦ ¦ Cartdao.java
¦ ¦ Itemdao.java
¦ ¦ Userdao.java
¦ ¦
¦ +---online_shopping_cart
¦ ¦ JakartaRestConfiguration.java
¦ ¦
¦ +---resources
¦ JakartaEE8Resource.java
¦
+---resources
¦ +---META-INF
¦ persistence.xml
¦
+---webapp
¦ adminlogin.jsp
¦ admintask.jsp
¦ contact.jsp
¦ edititems.jsp
¦ index.jpg
¦ index.jsp
¦ manageitems.jsp
¦ manageuser.jsp
¦ newitems.jsp
¦ publicshoplist.jsp
¦ shopitems.jsp
¦ thankyou.jsp
¦ usercart.jsp
¦ usereg.jsp
¦ userlogin.jsp
¦ usertask.jsp
¦
+---META-INF
¦ context.xml
¦
+---WEB-INF
beans.xml
web.xml
To contribute to this project:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
Keval