Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a1e77a0
Files upload
shashirajraja Jul 25, 2018
7ee02cf
Readme updated
shashirajraja Oct 8, 2018
9f0a5c0
Update README.md
shashirajraja Oct 8, 2018
38443e5
Update README.md
shashirajraja Jan 25, 2019
3797143
updated
shashirajraja Sep 11, 2019
1b4b4c6
online book store
ajay109458 Oct 24, 2019
ac66a6b
Merge pull request #1 from ajay109458/gh-pages
shashirajraja Oct 27, 2019
1015838
UserLogin Page Mistakes Updated
shashirajraja Nov 7, 2019
710dd9a
MySql Connector Added
shashirajraja Nov 7, 2019
0c688cf
Book Removal Problem Solved
shashirajraja Nov 7, 2019
05de44d
#Bug Fixed
shashirajraja Nov 7, 2019
b91b163
Readme Updated
shashirajraja Nov 7, 2019
718ab80
Database Creation in MySql
shashirajraja Nov 8, 2019
b09968e
Dummy Database Updated
shashirajraja Nov 8, 2019
78d978f
Update Dummy Database
shashirajraja Nov 8, 2019
4d332bc
Database Link Added
shashirajraja Nov 13, 2019
0edb59e
#Bug for pull request #5 Fixed
shashirajraja Jan 13, 2020
9ec56e6
web.xml updated
shashirajraja Jun 12, 2020
2dd23f6
Bump mysql-connector-java from 5.1.45 to 8.0.16
dependabot[bot] Jul 2, 2020
1530761
Merge pull request #7 from shashirajraja/dependabot/maven/mysql-mysql…
shashirajraja Jul 2, 2020
5c0550d
Update README.md
Sushobh94 Oct 8, 2020
93a8c9d
Merge pull request #11 from Sushobh94/patch-1
shashirajraja Feb 17, 2021
ecb6dff
Updated Website Front End Design Link to Readme
shashirajraja Feb 17, 2021
33a359b
Update README.md
shashirajraja Feb 17, 2021
717733a
Updated Readme.doc
NagiReddyDEVOPS Apr 2, 2021
4922504
Test added
NagiReddyDEVOPS Apr 2, 2021
38ef848
Sample.html modified
NagiReddyDEVOPS Apr 2, 2021
5660409
Sample.html back to normal
NagiReddyDEVOPS Apr 2, 2021
a1eedba
Changed Sample.html
NagiReddyDEVOPS Apr 2, 2021
bd6e1c7
Added web.txt
NagiReddyDEVOPS May 20, 2021
703d090
Updated web.txt
NagiReddyDEVOPS May 20, 2021
0cc0d7c
Create Test12345
NagiReddyDEVOPS Nov 29, 2021
6e0038d
Update Test
NagiReddyDEVOPS Aug 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="OnlineBookStore"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="build/classes"/>
</classpath>
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target/
/build/
37 changes: 37 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>onlinebookstore</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
12 changes: 12 additions & 0 deletions .settings/.jsdtscope
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="WebContent"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
11 changes: 11 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
9 changes: 9 additions & 0 deletions .settings/org.eclipse.wst.common.component
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="onlinebookstore-0.0.1-SNAPSHOT">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/OnlineBookStore"/>
<property name="context-root" value="onlinebookstore"/>
<property name="java-output-path" value="/onlinebookstore/build/classes"/>
</wb-module>
</project-modules>
7 changes: 7 additions & 0 deletions .settings/org.eclipse.wst.common.project.facet.core.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.web" version="3.1"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>
1 change: 1 addition & 0 deletions .settings/org.eclipse.wst.jsdt.ui.superType.container
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
1 change: 1 addition & 0 deletions .settings/org.eclipse.wst.jsdt.ui.superType.name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Window
2 changes: 2 additions & 0 deletions .settings/org.eclipse.wst.validation.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
disabled=06target
eclipse.preferences.version=1
28 changes: 28 additions & 0 deletions Dummy_Database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
### Copy and Paste the following MYSQL commands to make a dummy database for this Project :


create database onlinebookstore;

use onlinebookstore;

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

create table 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('10101','Programming in C','James k Wick',500,5);

insert into books values('10102','Learn Java','Scott Mayers',150,13);

insert into books values('10103','Database Knowledge','Charles Pettzoid',124,360);

insert into books values('10104','Let us c++','Steve Macclen',90,111);

insert into books values('10105','Success Key','Shashi Raj',5000,15);

insert into users values('User','Password','First','User','My Home','42502216225','User@gmail.com',2);

insert into users values('Admin','Admin','Mr.','Admin','Haldia WB','9584552224521','admin@gmail.com',1);

insert into users values('shashi','shashi','Shashi','Raj','Bihar','1236547089','shashi@gmail.com',2);

commit;
10 changes: 10 additions & 0 deletions OnlineBookStore/constants/IDatabase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package constants;

public class IDatabase {

public static final String DRIVER_NAME = "com.mysql.jdbc.Driver";
public static final String CONNECTION_STRING = "jdbc:mysql://localhost:3306/onlinebookstore";
public static final String USER_NAME = "root";
public static final String PASSWORD = "root";

}
7 changes: 7 additions & 0 deletions OnlineBookStore/constants/IOnlineBookStoreConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package constants;

public interface IOnlineBookStoreConstants {
public static String CONTENT_TYPE_TEXT_HTML = "text/html";


}
56 changes: 56 additions & 0 deletions OnlineBookStore/servlets/AddBookServlet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package servlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;

import javax.servlet.GenericServlet;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import constants.IOnlineBookStoreConstants;
import sql.IBookConstants;

public class AddBookServlet extends GenericServlet{
public void service(ServletRequest req,ServletResponse res) throws IOException,ServletException
{
PrintWriter pw = res.getWriter();

res.setContentType(IOnlineBookStoreConstants.CONTENT_TYPE_TEXT_HTML);

String bCode = req.getParameter(IBookConstants.COLUMN_BARCODE);
String bName = req.getParameter(IBookConstants.COLUMN_NAME);
String bAuthor = req.getParameter(IBookConstants.COLUMN_AUTHOR);
int bPrice =Integer.parseInt(req.getParameter(IBookConstants.COLUMN_PRICE));
int bQty = Integer.parseInt(req.getParameter(IBookConstants.COLUMN_QUANTITY));

try {
Connection con = DBConnection.getCon();
PreparedStatement ps = con.prepareStatement("insert into " + IBookConstants.TABLE_BOOK + " values(?,?,?,?,?)");
ps.setString(1, bCode);
ps.setString(2, bName);
ps.setString(3, bAuthor);
ps.setInt(4, bPrice);
ps.setInt(5, bQty);
int k = ps.executeUpdate();
if(k==1)
{
RequestDispatcher rd = req.getRequestDispatcher("AddBook.html");
rd.include(req, res);
pw.println("<div class=\"tab\">Book Detail Updated Successfully!<br/>Add More Books</div>");
}
else
{
RequestDispatcher rd = req.getRequestDispatcher("AddBook.html");
pw.println("<div class=\"tab\">Failed to Add Books! Fill up CareFully</div>");
rd.include(req, res);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
48 changes: 48 additions & 0 deletions OnlineBookStore/servlets/AdminLoginServlet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package servlets;

import javax.servlet.*;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;

import constants.IOnlineBookStoreConstants;
import sql.IUserContants;

import java.io.*;
import java.sql.*;

public class AdminLoginServlet extends GenericServlet {
public void service(ServletRequest req, ServletResponse res) throws IOException, ServletException {
PrintWriter pw = res.getWriter();
res.setContentType(IOnlineBookStoreConstants.CONTENT_TYPE_TEXT_HTML);
String uName = req.getParameter(IUserContants.COLUMN_USERNAME);
String pWord = req.getParameter(IUserContants.COLUMN_PASSWORD);
try {
Connection con = DBConnection.getCon();
PreparedStatement ps = con.prepareStatement("SELECT * FROM " + IUserContants.TABLE_USERS + " WHERE "
+ IUserContants.COLUMN_USERNAME + "=? AND " + IUserContants.COLUMN_PASSWORD + "=? AND "
+ IUserContants.COLUMN_USERTYPE + "=1");
ps.setString(1, uName);
ps.setString(2, pWord);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
RequestDispatcher rd = req.getRequestDispatcher("Sample.html");

Cookie ck = new Cookie("usertype","admin");

rd.include(req, res);
pw.println("<div class=\"tab\">Admin login Successful</div>");
pw.println("<div class=\"tab\"><br/><a href=\"AddBook.html\">ADD BOOKS</a><br/></div>");
pw.println("<div class=\"tab\"><br/><a href=\"RemoveBooks.html\">REMOVE BOOKS</a><br/></div>");
pw.println("<div class=\"tab\"><br/><a href=\"viewbook\">VIEW BOOKS</a></div>");
} else {

RequestDispatcher rd = req.getRequestDispatcher("AdminLogin.html");
rd.include(req, res);
pw.println("<div class=\"tab\">Incorrect UserName or PassWord</div>");
}

} catch (Exception e) {
e.printStackTrace();
}
}
}
67 changes: 67 additions & 0 deletions OnlineBookStore/servlets/BuyBooksServlet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package servlets;
import java.io.*;
import java.sql.*;
import javax.servlet.*;

import constants.IOnlineBookStoreConstants;
import sql.IBookConstants;
import sql.IUserContants;
public class BuyBooksServlet extends GenericServlet{
public void service(ServletRequest req,ServletResponse res) throws IOException,ServletException
{
PrintWriter pw = res.getWriter();
res.setContentType(IOnlineBookStoreConstants.CONTENT_TYPE_TEXT_HTML);
try {
Connection con = DBConnection.getCon();
//ArrayList<Books> al = new ArrayList<Books>();
PreparedStatement ps = con.prepareStatement("Select * from " + IBookConstants.TABLE_BOOK);
ResultSet rs = ps.executeQuery();
RequestDispatcher rd = req.getRequestDispatcher("ViewBooks.html");
rd.include(req, res);
pw.println("<div class=\"tab hd brown \">Books Available In Our Store</div>");
pw.println("<div class=\"tab\"><form action=\"buys\" method=\"post\">");
pw.println("<table>\r\n" +
" <tr>\r\n" +
" <th>Books</th>\r\n" +
" <th>Code</th>\r\n" +
" <th>Name</th>\r\n" +
" <th>Author</th>\r\n" +
" <th>Price</th>\r\n" +
" <th>Avail</th>\r\n" +
" <th>Qty</th>\r\n" +
" </tr>");
int i=0;
while(rs.next())
{
String bCode = rs.getString(1);
String bName = rs.getString(2);
String bAuthor = rs.getString(3);
int bPrice = rs.getInt(4);
int bAvl = rs.getInt(5);
i=i+1;
String n = "checked"+ Integer.toString(i);
String q = "qty"+Integer.toString(i);
pw.println("<tr>\r\n" +
" <td>\r\n" +
" <input type=\"checkbox\" name="+n+" value=\"pay\">\r\n" + //Value is made equal to bcode
" </td>");
pw.println("<td>"+bCode+"</td>");
pw.println("<td>"+bName+"</td>");
pw.println("<td>"+bAuthor+"</td>");
pw.println("<td>"+bPrice+"</td>");
pw.println("<td>"+bAvl+"</td>");
pw.println("<td><input type=\"text\" name="+q+" value=\"0\" text-align=\"center\"></td></tr>");

}
pw.println("</table>\r\n" + "<input type=\"submit\" value=\" PAY NOW \">"+"<br/>"+
" </form>\r\n" +
" </div>");
//pw.println("<div class=\"tab\"><a href=\"AddBook.html\">Add More Books</a></div>");
}
catch(Exception e)
{
e.printStackTrace();
}
}

}
42 changes: 42 additions & 0 deletions OnlineBookStore/servlets/DBConnection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package servlets;
import java.sql.*;
import java.util.ResourceBundle;

import constants.IDatabase;

public class DBConnection {
private static Connection con;

private DBConnection(){};

static {

try {

Class.forName(IDatabase.DRIVER_NAME);

}
catch(Exception e)
{
e.printStackTrace();
}

try {

con = DriverManager.getConnection(IDatabase.CONNECTION_STRING, IDatabase.USER_NAME, IDatabase.PASSWORD);

}
catch (SQLException e) {

e.printStackTrace();

}


}//End of static block

public static Connection getCon()
{
return con;
}
}
Loading