Giter Club home page Giter Club logo

shashirajraja / shopping-cart Goto Github PK

View Code? Open in Web Editor NEW
188.0 7.0 286.0 5.34 MB

Online Shopping Cart E-Commerce Website Project in Java, JDBC, Servlets, JSP. Built for selling of goods online and managing the cart items of the user and providing them better facilities like adding items, removing items, increase or decrease item quantity.

License: Apache License 2.0

CSS 1.89% HTML 1.39% Java 96.72%
shopping-cart webdevelopment online-shopping-website java-shopping-cart java-projects ecommerce-project hacktoberfest online-shopping online-shopping-cart online-shopping-system

shopping-cart's Introduction

Online Shopping Cart (E-Commerce Website)

This is an E-Commerce Website build for selling of any electronics products online.

About

In this projects a user can visit the websites, registers and login to the website. They can check all the products available for shopping, filter and search item based on different categories, and then add to cart. They can add multiple item to the cart and also plus or minus the quantity in the cart. Once the cart is updated, the user can proceed to checkout and click the credit card payment details to proceed. Once the payment is success the orders will be placed and users will be able to see the orders details in the orders section along with the shipping status of the product.

The admin also plays an important role for this project as the admin is the one responsible for adding any product to the store, updating the items, removing the item from the store as well as managing the inventory. The admin can see all the product orders placed and also can mark them as shipped or delivered based on the conditions.

One of the best functionality that the projects include is mailing the customers, so once a user registers to the website, they will recieve a mail for the successful registration to the website, and along with that whenever a user orders any product or the product got shipped from the store, then the user will also receive the email for its confirmation. Sometimes, if the user tried to add any item which is out of stock, them they will get an email one the item is available again the stock.

Note: The payment page is created only for demo purpose and its not fully integrated with any payment gateway. So for now any credit card details will be accepted and the demo orders will be placed.

Highlights :--

The users will get a mail to their registered mail Id during:-

  • New User Registration
  • Order Successfully Placed
  • The Item was out of stock while exploring but now it got available in the store
  • Successful shipment and delivery of the Item

Technologies used:-

  1. Front-End Development:
  • HTML
  • CSS
  • Javascript
  • BootStrap
  1. Back-End Development:
  • Java [JDK 8+]
  • JDBC
  • Servlet
  • JSP
  1. Database:
  • MySql

================ Software And Tools Required ================

================= Dummy Database Initialization =================

STEP 1: Open MySQL Command Prompt or MySQL Workbench

STEP 2: Login to the administrator user of MySql: mysql -u <username> -p (Enter Password if asked)

STEP 3: Copy paste and execute the MySQL Query from the following file:-

======GENERATING GMAIL APP PASSWORD [For Mailing Functionalities]========

Step 1: Create a gmail account or login to existing account in any browser

Step 2 : Go to https://myaccount.google.com/security and check if 2 step verifications is enabled or not, enable it if not enabled

Step 3: Go to https://myaccount.google.com/apppasswords and enter password if asked

Step 4: In Select an App Section: select Other (custom name) => enter "Ellison Electronics" => Generate

Step 5: After that it will generate 16 digits app password which you need to copy and save for future configurations.

Step 6: Done : Now continue to importing the project. [Don't share the above password generated to anyone]

========== Importing and Running The Project Through Eclipse EE ==========

Step 1: Open Eclipse Enterprise Edition. [Install, if not already installed.]

Step 2: Click On File > Import > Git > Projects From Git > Clone Uri > Paste The Repository Url as: https://github.com/shashirajraja/shopping-cart.git> Select master Branch > Next > Next > Finish.

Step 3: Go inside Java Resources > src > application.properties and update the values as below:

  • a) Update value for db.username and db.password according to your installed mysql credentials.
  • b) Update value for mailer.email and mailer.password, with the same email and app password that you generated earlier in above section [ NOTE:Actual gmail password will not work]

Step 4: Right Click on Project > Run as > Maven Build > In the goals field enter "clean install" > apply > run

Step 5: Right Click On Project > Build Path > Configure Build Path > Libraries > Remove and Update Any Libraries if Red Mark Exists > Finish.

Step 6: Right Click on Project > maven > update project > select force update > apply > close

Step 7: Tomcat Configurations:

  • If Tomcat Server is not configured in Eclipse :

    • Right Click On Project > Run As > Run On Server > Manually Define a new server > Select server type > select Tomcat v8.0+ > (Select Tomcat V8.0+ Installation Location If Asked) > Next > Add the current project > Finish.
  • Else If Tomcat Server is already configured in Eclipse:

    • Right Click On Project > Run As > Run On Server > Select Tomcat Version > Next > Add the project > Finish.

      or

    • You can directly goto server tab, select the tomcat server and use the debug or run button to start the previously ran project

Step 8: Check Running The Site At http://localhost:8080/shopping-cart/

Step 9: [To Change the Port, if getting error like 'port already in use'] Open The Server Tab > Double Click On Tomcat Server > Ports > Change The Port Number For Http/1.1 To 8083 > Close And Save. Now Start and you can access the project on http://localhost:8083/shopping-cart/

Step 10: Default Username And Password For Admin Is "[email protected]" And "admin"

Step 11: The default Username And Password For User Is "[email protected]" And "guest"

FAQ

Question:1 Unable to Connect to Database?

Answer: Please check you have installed the mysql correctly and have updated the correct db details in application.properties file. Also you can try doing maven clean install and force update the project and restart.


Note:- This is a Sample Project for learning purpose, we have not much considered of web security.

Some Screenshots for the project:

  • Home Page image

  • Login Page image

  • Register Page image

  • Category Wise Product Filter image

  • Cart Items image

  • Credit Card Payment image

  • Order Details & Status image

  • User Profile image

  • Admin Home image

  • Stock Items image

  • Shipped Items image

  • Recent Orders yet to be shipped image

  • Add Product to the stock image

  • Remove Product from the stock image

  • Update the stock item image

  • Sample Email for order placed

image
  • Class Diagram
image

"Suggestions and project improvement ideas are welcomed!"

Thanks a lot,
Project Leader
Shashi Raj

shopping-cart's People

Contributors

shashirajraja avatar the-suman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

shopping-cart's Issues

Permission to shashirajraja/shopping-cart.git denied to Nani6318 I want to use this project in my github portal

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

sendRedirect potnetial IOExcpetion thrown with no try-catch

Describe the bug
A clear and concise description of what the bug is.
sendRedirect() is called with no try-catch clause which has th epotential to throw an IOException.
To Reproduc e
Steps to reproduce the behavior:

  1. IF there is a netowork or issue with the servlet container. an IOException error is thrown.

Expected behavior
A try-catych clause to handle cases of these errors.

Desktop (please complete the following information):

  • Linux Ubuntu
  • Browser [Chrome]
  • Version 123.0.6312.106

Issue

Can you upload the sql file please.

page not loading properly and content not loading // http status 404

I have followed the instructions for installation from the youtube video but I have come up with a problem of not loading some contexts in the page.
i am not able to view the cart and login into the webpage and it show http response error 404 where pages are present but i am not able to access it
i have connected the database properly and have the requirements installed (screenshots given)
product category not working
i have installed this using git from the repo directly into eclipse


i am mainly getting a http 404 error , which is the following

HTTP Status 404 โ€“ Not Found
Type Status Report

Message The requested resource [/shopping-cart/LoginSrv] is not available

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

Screenshots
Screenshot 2023-10-17 135105
Screenshot 2023-10-19 003329
Screenshot 2023-10-19 003414
Screenshot 2023-10-19 003502
Screenshot 2023-10-17 133846
Screenshot 2023-10-17 133941


  • OS: windows 11
  • Browser - microsoft edge
  • tomcat version 10
  • maven build vesion 4

console log:
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version name: Apache Tomcat/10.0.27
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Oct 3 2022 14:18:31 UTC
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version number: 10.0.27.0
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 11
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 10.0
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\Program Files\Java\jdk-20
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 20.0.2+9-78
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: C:\Users\rutta\eclipse-workspace\ecommerce.metadata.plugins\org.eclipse.wst.server.core\tmp0
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: D:\devesh-coding\java-coding\tomcat\apache-tomcat-10.0.27
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\Users\rutta\eclipse-workspace\ecommerce.metadata.plugins\org.eclipse.wst.server.core\tmp0
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=D:\devesh-coding\java-coding\tomcat\apache-tomcat-10.0.27
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\Users\rutta\eclipse-workspace\ecommerce.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dstdout.encoding=UTF-8
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dstderr.encoding=UTF-8
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -XX:+ShowCodeDetailsInExceptionMessages
Oct 19, 2023 12:28:50 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path: [C:\Program Files\Java\jdk-20\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\Program Files\Java\jdk-20\bin;C:\Program Files\MySQL\mysql-connector-j-8.1.0\mysql-connector-j-8.1.0;C:\ApacheMaven\apache-maven-3.9.5-bin\apache-maven-3.9.5\bin;C:\Program Files\Git\cmd;C:\Program Files\MySQL\MySQL Shell 8.0\bin;C:\Users\rutta\AppData\Local\Programs\Python\Python312\Scripts;C:\Users\rutta\AppData\Local\Programs\Python\Python312;C:\Users\rutta\AppData\Local\Microsoft\WindowsApps;C:\Users\rutta\AppData\Roaming\npm;C:\Users\rutta\AppData\Local\GitHubDesktop\bin;C:\Users\rutta\AppData\Local\Programs\Microsoft VS Code\bin;.]
Oct 19, 2023 12:28:50 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Oct 19, 2023 12:28:50 AM org.apache.catalina.startup.Catalina load
INFO: Server initialization in [1502] milliseconds
Oct 19, 2023 12:28:50 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
Oct 19, 2023 12:28:50 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet engine: [Apache Tomcat/10.0.27]
Oct 19, 2023 12:28:51 AM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [131] milliseconds.
Oct 19, 2023 12:28:54 AM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Oct 19, 2023 12:28:54 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Oct 19, 2023 12:28:54 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in [3581] milliseconds
.
.
.
.
.
.
i probably think database or install error or code error i am actually recieving

please resolve this error in this project @shashirajraja @the-suman

conn null

org.apache.jasper.JasperException: An exception occurred processing [/index.jsp] at line [47]

44: products = prodDao.getAllProductsByType(type);
45: message = "Showing Results for '" + type + "'";
46: } else {
47: products = prodDao.getAllProducts();
48: }
49: if (products.isEmpty()) {
50: message = "No items found for the search '" + (search != null ? search : type) + "'";

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:599)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:488)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:380)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:328)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)

Root Cause

java.lang.NullPointerException: Cannot invoke "java.sql.Connection.prepareStatement(String)" because "con" is null
com.shashi.service.impl.ProductServiceImpl.getAllProducts(ProductServiceImpl.java:196)
org.apache.jsp.index_jsp._jspService(index_jsp.java:183)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:456)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:380)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:328)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)

Note The full stack trace of the root cause is available in the server logs.

Even though mysql is running fine, it still says conn is null.

Possible null pointer dereference of conn in com.shashi.service.impl.UserServiceImpl.registerUser(UserBean)

Describe the bug
There is a branch of statement that, if executed, guarantees that a null value will be dereferenced, which would generate a NullPointerException when the code is executed. Line 46 in UserServiceImpl.java

Found through FindBUgs, white box static code testing. ps = conn.prepareStatement("insert into " + IUserConstants.TABLE_USER + " values(?,?,?,?,?,?)");

if Conn is null this could cause issues. there is line 40 which checks if conn is null but this should also be used for the insert statement on line 46

if (conn != null) {....

Malicious code vunerability

I have come across a malicious code vulnerability.

image

The issue occurs in the class OrderDetails on line 59.

It states the error: This code stores a reference to an externally mutable object into the internal representation of the object.ย  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations

Security Bug(Cross Site Scripting)

Describe the bug
The website is having a security vulnerability. This could potentially put user accounts at risk, and allow malicious activities to take place. I have attached the screenshots of performing Cross-Site Scripting "<script>alert("ATTACK")</script>" on text input boxes.

Steps to reproduce the behavior:

  1. Go to HomePage
  2. Type <script>alert("ATTACK")</script> in search items text box
  3. alert box will pop up (bug).

Expected behavior
The website should not allow any type Cross-Site Scripting injection. However, it allowed the Cross-Site Scripting injection and an alert box appeared (bug).

Screenshots
Screenshot 2023-08-13 at 5 36 59 PM

Screenshot 2023-08-13 at 5 37 04 PM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.