Giter VIP home page Giter VIP logo

shashirajraja / onlinebookstore Goto Github PK

View Code? Open in Web Editor NEW
397.0 11.0 2.0K 4.63 MB

The Online Book Shopping Store to manage, buy, add, remove and sell books. Book name and Quantity selection, auto receipt generated and payment options. Login and logout security for both user and admin. Seperate Profile for all.

HTML 25.26% Java 73.58% Shell 0.08% Procfile 0.08% CSS 1.01%
book store onlinebookstore bookstore bookstorejavaproject java-project online-book-store webdevelopment jdbc book-shopping

onlinebookstore's Introduction

  • User Login Credentials: (shashi/shashi)
  • Admin Login Credentials: (Admin/Admin)

About

A user-friendly Online Bookstore project in which users can log in or register, view the available books, select books along with their quantity, and buy them. Users can also get payment receipts after successful payment. The project can also be used by the administrator, who can add new books, remove books, increase and decrease the quantity of books, change the price of the books as well as maintain the selling history of books.

onlinebookstore

This Website is built for following purpose:-

  • For Selling books online.
  • Maintaining books selling history.
  • Adding and managing books.
  • User Friendly.
  • For Implementation of Http Servlets in Java.
  • This is a Mini-project developed using Java, Jdbc, And Servlets.

Admin Have Following Access for this online store site:-

  • Add New Books.
  • View Books Available.
  • Remove Books.
  • Increase Books Amount.

Users Have Following Access for this online store site:-

  • Create New Account or Register.
  • Login.
  • View Available Books.
  • Select Books to Buy.
  • Select Books Quantity.
  • Buy Books.
  • Get Payment Receipt.

Technologies used:-

  1. Front-End Development:
  • HTML
  • CSS
  • Javascript
  • BootStrap
  1. Back-End Development:
  • Java [JDK 8+]
  • JDBC
  • Servlet
  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 as : mysql -u <username> -p (Enter Password if asked)

STEP 3: Copy paste the following MySql Commands-

create database if not exists onlinebookstore;

use onlinebookstore;

create table if not exists books(barcode varchar(100) primary key, name varchar(100), author varchar(100), price int, quantity int);

create table if not exists users(username varchar(100) primary key,password varchar(100), firstname varchar(100),
    lastname varchar(100),address text, phone varchar(100),mailid varchar(100),usertype int);

insert into books values('9780134190563','The Go Programming Language','Alan A. A. Donovan and Brian W. Kernighan',400,8);
insert into books values('9780133053036','C++ Primer','Stanley Lippman and Josée Lajoie and Barbara Moo',976,13);
insert into books values('9781718500457','The Rust Programming Language','Steve Klabnik and Carol Nichols',560,12);
insert into books values('9781491910740','Head First Java','Kathy Sierra and Bert Bates and Trisha Gee',754,23);
insert into books values('9781492056300','Fluent Python','Luciano Ramalho',1014,5);
insert into books values('9781720043997','The Road to Learn React','Robin Wieruch',239,18);
insert into books values('9780132350884','Clean Code: A Handbook of Agile Software Craftsmanship','Robert C Martin',288,3);
insert into books values('9780132181273','Domain-Driven Design','Eric Evans',560,28);
insert into books values('9781951204006','A Programmers Guide to Computer Science','William Springer',188,4);
insert into books values('9780316204552','The Soul of a New Machine','Tracy Kidder',293,30);
insert into books values('9780132778046','Effective Java','Joshua Bloch',368,21);
insert into books values('9781484255995','Practical Rust Projects','Shing Lyu',257,15);
insert into users values('demo','demo','Demo','User','Demo Home','42502216225','[email protected]',2);
insert into users values('Admin','Admin','Mr.','Admin','Haldia WB','9584552224521','[email protected]',1);
insert into users values('shashi','shashi','Shashi','Raj','Bihar','1236547089','[email protected]',2);

commit;

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

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

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

Step 2. a: Go inside src/main/resources > application.properties and update the value of database details as per your usage, like db.driver, db.host, db.username and db.password according to your installed mysql/postgresql admin user credentials.

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

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

Step 3: [Only If Tomcat Server is not configured in Eclipse] : Right Click On Project > Run As > Run On Server > Select Tomcat V8.0 > (Select Tomcat V8.0 Installation Location If Asked) Next > Add onlinebookstore > Finish.

Step 4: In The Server Tab > Double Click On Tomcat Server > Ports > Change The Port Number For Http/1.1 To 8083 > Close And Save.

Step 5: Right Click On Project > Run As > Run On Server > Select Tomcat v8.0 > Next > Add All> Done.

Step 6: Check Running The Site At http://localhost:8083/onlinebookstore/

Step 7: Default Username And Password For Admin Is "Admin" And "Admin"

Step 8: The default Username And Password For User Is "shashi" And "shashi"

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:- Considering this as a Sample Project, we have not much considered of web security.

Some Screenshots for the project:

image

image

image

image

image

"Suggestions and project improvement ideas are welcomed!"

Thanks a lot,
Project Leader
Shashi Raj

onlinebookstore's People

Contributors

abhay-y avatar ajay109458 avatar ajith87907 avatar anurag-4508 avatar arka200313 avatar arvindcb avatar ayushete02 avatar chaudhary-99 avatar dependabot[bot] avatar edvenswa-tech avatar guneshmunjal avatar lan10rn avatar mrshrivastava avatar pooranjoyb avatar ragultw avatar rajput999 avatar ramshaashraf avatar rebel-04 avatar riyasanvi7 avatar rrk-coder avatar sachdevlaksh avatar shashirajraja avatar sinaps07 avatar solanki-jignesh avatar sushobh94 avatar the-suman avatar utdude avatar vivektiwari1605 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  avatar  avatar  avatar  avatar

onlinebookstore's Issues

[BUG]

Description

When a databsae conncetion is made, the connection is not closed after its use. Further, that close call must be made in a finally block otherwise an exception could keep the call from being made.

Expected behavior

A final clause after the try-catch to close the database connection

Actual behavior

No final clause to close the database conneciton

Possible fix

Add a final clause to close the connection

Steps to reproduce

Selecting a book which calls the getBookById() method call that then creates a database connection

Context

Exception was thrown when querying book.

Additional information

No response

Facing internal errors like "HTTP Status 500, 404"

hello
I tried to run the project on my laptop in the same way as your procedure in the readme file.
The java, tomcat, MySQL connections are smooth and stable but whenever I try to run the project,
Firstly it will show the home page correctly.
But when I try to do admin login or user login or see available books, it gives me errors like
" HTTP STATUS 404 - The origin server did not find a current representation for the target resource or is not willing to disclose that one exists."
Is there any update to the content or any other thing, I tried general solutions available on the Net, but nothing worked.
Can you please tell me the solution?

@shashirajraja #

[BUG] - Null Pinter Reference - cartItems - ProcessPaymentServlet.Java

Description

In ProcessPaymentServlet.java at line 48, there is the possibility of hitting a null pointer reference. Line 46 has a condition to check != null how ever that condition does not cover the for loop of the cartItem list. The If condition (line 46) needs to cover the entire for loop starting at line 48.

Expected behavior

list does not hit null reference when iterating the loop at checkout

Actual behavior

list hits null reference and an error is thrown.

Possible fix

The If condition (line 46) needs to cover the entire for loop starting at line 48.

Steps to reproduce

In ProcessPaymentServlet.java at line 48, there is the possibility of hitting a null pointer reference. Line 46 has a condition to check != null how ever that condition does not cover the for loop of the cartItem list. The If condition (line 46) needs to cover the entire for loop starting at line 48.

Context

Was doing code review and running find bugs on the code

Additional information

No response

Create application with REST API + Hibernate

@shashirajraja

Since nowadays servlets are being used very less at the industry level. But I appreciate your effort in creating the project.

I have created a REST API application for your online store application. Used HIbernate instead of JDBC behind the scene.
Refer - Book Store App

I hope it will be great learning for you.

Add SECURITY.md

Hey there!

I belong to an open source security research community, and a member (@S54r) has found an issue, but doesn’t know the best way to disclose it.

If not a hassle, might you kindly add a SECURITY.md file with an email, or another contact method? GitHub recommends this best practice to ensure security issues are responsibly disclosed, and it would serve as a simple instruction for security researchers in the future.

Thank you for your consideration, and I look forward to hearing from you!

(cc @huntr-helper)

Icon for onlinebookstore

I would like to add a relevant and suitable icon for the website. Kindly assign this task to me.

Read database properties from config.properties file

Currently the database details configurations is hardcoded in DatabaseConfig.java file, but we need to read it from some properties file and use
Like config.properties file, which should contains all the db properties like dbName, dbHost, etc.

buttons are looking like old uncles

could you assign me this issue so that i can make them look good .it will require a few lines of code .
please assign me this under hactoberfest
Capture 15

Header With Logo

Detailed description

Header is very important part of website soo a can make the header for the website and that will match the design of the website

Context

Header is very important part of website without header website is incomplete.
header will make the website better.

Possible implementation

No response

Additional information

you can see my website website

[FEATURE] Improve the UI and make some transitions and animations in the website

Detailed description

Improve the UI and make some transitions and animations in the website

  • Add more readability to the webpages
  • Simplify the structure of interlinked webpages

Context

to Improve the readabilty of the content and enhancement of the user experience or user time on the website

Possible implementation

No response

Additional information

No response

Refactoring Suggestion - Dead Code Cleanup

Hi shashirajraja,

I hope this message finds you well. During my review of your codebase, I noticed the presence of dead code in the User class, particularly in the method retrieveFromHttpServletRequest, where significant portions of code are commented out and not actively used.

Why Refactor?

Code Cleanup: Removing dead code contributes to a cleaner and more maintainable codebase.
Reduced Complexity: Deleting unused code reduces the overall complexity of the project, making it easier for developers to understand and navigate.
Refactoring Proposal:

package com.bittercode.model;

import java.io.Serializable;
import java.util.List;

public class User implements Serializable {

    private String emailId;
    private String password;
    private String firstName;
    private String lastName;
    private Long phone;
    private String address;
    private List<UserRole> roles;

    // Existing getter and setter methods

    // Dead code removal
    // public static User retrieveFromHttpServletRequest(HttpServletRequest req) {
    //     // ... (previously commented out code)
    // }
}

I recommend deleting the commented-out code within the retrieveFromHttpServletRequest method, as it is currently not actively used and might lead to confusion for developers maintaining the codebase.

Additionally, please consider performing a broader sweep across your project to identify and delete any other unneeded files or dead code segments. Keeping the codebase free of unused artifacts enhances its clarity and maintainability.

Feel free to incorporate this suggestion, and if you have any questions or need further assistance, please don't hesitate to reach out.

aligned properly

these text boxes should be aligned properly
Capture14
could you assign me this under hactoberfest

[Entering the null values in user registration giving the result registration successfull]

Description

we have'nt created the null values restriction for the fields , like if we dont enter the password or dont enter the all fields still its shows the registration successfully. We should have the pattern matching for the email as well as phone number.

Expected behavior

instead of redirecting page to regitration successfully for null values, it should thrown an error and show it in next page

Actual behavior

it is accepting null values ,

Possible fix

we should add the not null in database field and as well as in the html code we should place placeholder and pattern matching for the input fields.

Steps to reproduce

create table if not exists users(username varchar(100) primary key,password varchar(100) not null, firstname varchar(100) not null,
lastname varchar(100),address text not null, phone varchar(100 ) not null,mailid varchar(100) unique,usertype int) ;
2.
RequestDispatcher rd = req.getRequestDispatcher("userreg");
rd.include(req, res);
pw.println("Sorry for interruption! Register again");
// redirection to empty page

Context

when i tried to put null values its shows the ambigous result.

Additional information

No response

Update README.md file

Hey! I would like to help update the README.md file as most of the content seems to be repetitive. Kindly assign it to me.

Add more books in the list

I want to add more books to the list as it is a library.
Can I make this contribution under hacktoberfest'22?

the button is not styled

this button should be styled accordingly with the website

kindly assign me this under hactoberfest

Capture 13

Hover Effect

Detailed description

I can add beautiful hover effect in your website header and in all buttons which will match the design of your website.
please @shashirajraja assign this issue to me.

Context

With hover effect website looks more attractive

Possible implementation

No response

Additional information

No response

HTTP STATUS 500- INTERNAL SERVER ERROR

85a110dd-28b0-406b-96a7-1343e6d11f0f
its showing us this error:
TYPE: EXCEPTION REPORT
MESSAGE: ERROR INSTALLING SERVLET CLASS
DESCRIPTION:THE SERVER ENCOUNTERED AN UNEXPECTED CONFITION THAT PREVENTED IT FROM FULFILLING THE REQUEST
error instantiating servlet class
WhatsApp Image 2022-04-25 at 6 32 06 PM

Enhancing inputs by adding labels and placeholders

Reason/Context

Why we need this improvement?
In this current version of the page, there is no labels or placeholders in the input section.

How will this change help?
It will enhance the UI of the webpage. It will ensure users to type into the input section of the page by just clicking on the labels provided. Hence giving a better user-experience.

Description

What changes have to be introduced?
Few changes needs to be done where placeholders and labels are to be added.

Will this be a breaking change?
No, it will just make the heading quote animated.

How could it be implemented/designed?
This can be achieved by adding adding labels and placeholder text in each of the inputs,
i.e, by writing few lines of codes in all the html files containing input tags.

Want to Work on this under Hacktoberfest2022. Please assign me. @shashirajraja

[Home buttons ui improve]

Description

Hey,
Please assign this issue so I can make the home screen buttons more awesome.

Expected behavior

The buttons will get more attractive

Actual behavior

Buttons are not too attractive

Possible fix

No response

Steps to reproduce

  1. Make buttons UI more attractive

Context

There is a shadow bug and the button UI is not attractive.

Additional information

No response

Getting white screen

I am getting white screen whenever I click on servlet pages like books available and admin login
image

Refactoring Suggestion - Address Class

THIS ISSUE IS POSTED AS A COLLEGE ASSIGNMENT ON BAD CODING SMELLS AND REFACTORING TECHNIQUES. PLEASE CLOSE THE ISSUE IF IT IS OF NO USE.

Hi shashirajraja,

I hope this message finds you well. After reviewing the Address class in your codebase, I wanted to propose a potential improvement and suggest incorporating the "Remove Setting Method" refactoring technique.

Why Refactor?

Encapsulation and Cohesion: The current class primarily acts as a data holder, and adding meaningful behavior to the class can enhance encapsulation and cohesion.
Maintainability: By introducing constructor-based initialization and removing setter methods, you improve the class's predictability and make it easier to maintain.
Avoiding Redundancy: Implementing methods like equals(), hashCode(), and providing a custom toString() can contribute to a cleaner, more organized design.
Refactoring Proposal:

import java.util.Objects;

public class Address {
    private final String addressLine1;
    private final String addressLine2;
    private final String city;
    private final String state;
    private final String country;
    private final long pinCode;
    private final String phone;

    public Address(String addressLine1, String addressLine2, String city, String state, String country, long pinCode, String phone) {
        this.addressLine1 = addressLine1;
        this.addressLine2 = addressLine2;
        this.city = city;
        this.state = state;
        this.country = country;
        this.pinCode = pinCode;
        this.phone = phone;
    }

    // Additional methods for better functionality
    public String getAddressSummary() {
        return String.format("%s, %s, %s, %s, %s", addressLine1, addressLine2, city, state, country);
    }

    // Implementing equals() and hashCode() for better object comparison
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Address address = (Address) o;
        return pinCode == address.pinCode &&
                Objects.equals(addressLine1, address.addressLine1) &&
                Objects.equals(addressLine2, address.addressLine2) &&
                Objects.equals(city, address.city) &&
                Objects.equals(state, address.state) &&
                Objects.equals(country, address.country) &&
                Objects.equals(phone, address.phone);
    }

    @Override
    public int hashCode() {
        return Objects.hash(addressLine1, addressLine2, city, state, country, pinCode, phone);
    }

    // Additional methods as needed

    @Override
    public String toString() {
        return "Address{" +
                "addressLine1='" + addressLine1 + '\'' +
                ", addressLine2='" + addressLine2 + '\'' +
                ", city='" + city + '\'' +
                ", state='" + state + '\'' +
                ", country='" + country + '\'' +
                ", pinCode=" + pinCode +
                ", phone='" + phone + '\'' +
                '}';
    }
}

By removing the setter methods, the class becomes immutable, which has several advantages, including improved thread safety and reasoning about the state of objects.

Feel free to incorporate this suggestion and reach out if you have any questions or need further clarification.

Issue Regarding Responsiveness Of User Interface

The Webpage Is Very Much Responsive On Devices Having Small Screen Sizes But The Only Problem Is That The Background Image Of The User Interface Is Getting Replicated Rather Than Getting Fit To The Device Screen

[FEATURE] UI Improvement of the website

Detailed description

Would like to improve the look of the buttons , improve font , alignment of headings, and better colour combinations of the website

Context

Can improve the user experience alot

Possible implementation

No response

Additional information

No response

Maven Package issue

Hi @shashirajraja .

while packing using mvn package from Jenkins, only the WebContent folder is packing under the created war file and while logging in getting servlets not found error.
could you please help me to pack all the folders and files from the given repository?

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.