Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added kickers/Asics Lethal Speed.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kickers/Nike-Revolution-4-Walking-Shoes.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kickers/ShoeImage/Adidas-Originals-Superstar.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kickers/ShoeImage/Adidas-Pureboost-Go.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kickers/ShoeImage/Adilette-Aqua-Slides.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kickers/ShoeImage/Adilette-Slides.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kickers/ShoeImage/Classic-Fila-Logo-Sneaker.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kickers/ShoeImage/Disruptor-II-Leather-Shoe.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kickers/ShoeImage/Eezay-Flip-flops.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kickers/ShoeImage/Fila-Drifter-Slider.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kickers/ShoeImage/Nike-Benassi-Slide.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kickers/ShoeImage/Nike-Kepa-Kai-Flip-Flops.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
80 changes: 80 additions & 0 deletions kickers/WEB-INF/classes/CategoryQueryServlet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class CategoryQueryServlet extends HttpServlet { // JDK 6 and above only

// The doGet() runs once per HTTP GET request to this servlet.
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// Set the MIME type for the response message
response.setContentType("text/html");
// Get a output writer to write the response message into the network socket
PrintWriter out = response.getWriter();

Connection conn = null;
Statement stmt = null;
try {
// Step 1: Create a database "Connection" object
// For MySQL
Class.forName("com.mysql.jdbc.Driver"); // Needed for JDK9/Tomcat9
conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/kickers?useSSL=false&serverTimezone=UTC", "myuser", "xxxx"); // <<== Check

// Step 2: Create a "Statement" object inside the "Connection"
stmt = conn.createStatement();

// Step 3: Execute a SQL SELECT query
String[] category = request.getParameterValues("category"); // Returns an array
if (category == null) {
out.println("<h2>Please go back and select an author</h2>");
return; // Exit doGet()
} else out.println(category[0]);
String sqlStr = "SELECT shoes.name, shoes.brand, shoes.category, shoes.price, shoes.qty, shoes.colour, shoe_image.location FROM shoes, shoe_image WHERE shoes.id = shoe_image.id AND category = "
+ "'" + request.getParameter("category") + "'"
+ " AND qty > 0 ORDER BY name ASC, brand ASC";

// Print an HTML page as output of query
out.println("<html><head><h1>Query Results</h1></head><body>");
out.println("<h2>Thank you for your query.</h2>");
out.println("<p>You query is: " + sqlStr + "</p>"); // Echo for debugging
ResultSet rset = stmt.executeQuery(sqlStr); // Send the query to the server

// Step 4: Process the query result
int count = 0;
while(rset.next()) {
// Print a paragraph <p>...</p> for each row
out.println("<p>" + rset.getString("shoes.name"));
out.println("<p>$" + rset.getDouble("shoes.price") + "</p>");
out.println("<img src='ShoeImage/" + rset.getString("shoe_image.location") + "' alt ='picture'/><br></br>");
// out.println("<p>" + rset.getString("name")
// + ", " + rset.getString("brand")
// + ", " + rset.getString("colour")
// + ", $" + rset.getDouble("price") + "</p>");
++count;
}
out.println("<p>==== " + count + " records found ====</p>");
out.println("</body></html>");
} catch (SQLException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} finally {
out.close();
try {
// Step 5: Close the Statement and Connection
if (stmt != null) stmt.close();
if (conn != null) conn.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
@Override
public void doPost (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response); // Re-direct POST request to doGet()
}
}
Binary file modified kickers/WEB-INF/classes/KickersOrderServlet.class
Binary file not shown.
28 changes: 14 additions & 14 deletions kickers/WEB-INF/classes/KickersOrderServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,37 @@ public void doGet(HttpServletRequest request, HttpServletResponse response)
// Step 3: Execute a SQL SELECT query
out.println("<html><head><title>Order Results</title></head><body>");

// Retrieve the books' id. Can order more than one books.
// Retrieve the shoes' id. Can order more than one shoes.
String[] ids = request.getParameterValues("id");
if (ids != null) {
String sqlStr;
int count;

// Process each of the books
// Process each of the shoes
for (int i = 0; i < ids.length; ++i) {
// Update the qty of the table books
sqlStr = "UPDATE books SET qty = qty - 1 WHERE id = " + ids[i];
// Update the qty of the table shoes
sqlStr = "UPDATE shoes SET qty = qty - 1 WHERE id = " + ids[i];
out.println("<p>" + sqlStr + "</p>"); // for debugging
count = stmt.executeUpdate(sqlStr);
out.println("<p>" + count + " record updated.</p>");

String[] files = request.getParameterValues("fileToUpload"); //file upload
if (files != null){
String fileString = files[i]; //assuming can only upload one file
out.println("<p>The file was uploaded: " + fileString + "</p>");
fileString = "INSERT INTO files (id, image) VALUES("+ ids[i] + ", LOAD_FILE('C:/Users/iisonya/Downloads/"+ fileString +"'))";
out.println("<p>" + fileString + "</p>");
count = stmt.executeUpdate(fileString);
out.println("<p>" + count + " record inserted.</p>");
} else out.println("<p>The file was NOT uploaded </p>");
// String[] files = request.getParameterValues("fileToUpload"); //file upload
// if (files != null){
// String fileString = files[i]; //assuming can only upload one file
// out.println("<p>The file was uploaded: " + fileString + "</p>");
// fileString = "INSERT INTO files (id, image) VALUES("+ ids[i] + ", LOAD_FILE('C:/Users/iisonya/Downloads/"+ fileString +"'))";
// out.println("<p>" + fileString + "</p>");
// count = stmt.executeUpdate(fileString);
// out.println("<p>" + count + " record inserted.</p>");
// } else out.println("<p>The file was NOT uploaded </p>");

// Create a transaction record
sqlStr = "INSERT INTO order_records (id, qty_ordered) VALUES ("
+ ids[i] + ", 1)";
out.println("<p>" + sqlStr + "</p>"); // for debugging
count = stmt.executeUpdate(sqlStr);
out.println("<p>" + count + " record inserted.</p>");
out.println("<h3>Your order for book id=" + ids[i]
out.println("<h3>Your order for shoes id=" + ids[i]
+ " has been confirmed.</h3>");
}
out.println("<h3>Thank you.<h3>");
Expand Down
10 changes: 10 additions & 0 deletions kickers/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

<!-- To save as "ebookshop\WEB-INF\web.xml" -->

<servlet>
<servlet-name>CategoryQuery</servlet-name>
<servlet-class>CategoryQueryServlet</servlet-class>
</servlet>

<servlet>
<servlet-name>KickersQuery</servlet-name>
<servlet-class>QueryServlet</servlet-class>
Expand Down Expand Up @@ -43,6 +48,11 @@
<!-- Note: All <servlet> elements must be placed
in front of <servlet-mapping> elements -->

<servlet-mapping>
<servlet-name>CategoryQuery</servlet-name>
<url-pattern>/categoryquery</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>KickersQuery</servlet-name>
<url-pattern>/query</url-pattern>
Expand Down
Binary file added kickers/header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 13 additions & 6 deletions kickers/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ <h3 class="w3-wide"><b>KICKERS</b></h3>
Kickers <i class="fa fa-caret-down"></i>
</a>
<div id="demoAcc" class="w3-bar-block w3-hide w3-padding-large w3-medium">
<a href="#" class="w3-bar-item w3-button">Sports Shoe</a>
<a href="#" class="w3-bar-item w3-button">Sneaker</a>
<a href="#" class="w3-bar-item w3-button">Slipper</a>
<a href="sportsshoe.html" class="w3-bar-item w3-button">Sports Shoe</a>
<a href="sneaker.html" class="w3-bar-item w3-button">Sneaker</a>
<a href="slipper.html" class="w3-bar-item w3-button">Slipper</a>
</div>


Expand All @@ -41,8 +41,7 @@ <h3 class="w3-wide"><b>KICKERS</b></h3>
</div>

<a href="login.html" class="w3-bar-item w3-button w3-padding">Log In</a>
<a href="#footer" class="w3-bar-item w3-button w3-padding">Search</a>
<a href="#footer" class="w3-bar-item w3-button w3-padding">Reviews</a>
<a href="#footer" class="w3-bar-item w3-button w3-padding">Reviews</a>
<a href="#footer" class="w3-bar-item w3-button w3-padding">Contact</a>
<a href="javascript:void(0)" class="w3-bar-item w3-button w3-padding" onclick="document.getElementById('newsletter').style.display='block'">Newsletter</a>
<a href="#footer" class="w3-bar-item w3-button w3-padding">Subscribe</a>
Expand All @@ -63,7 +62,15 @@ <h3 class="w3-wide"><b>KICKERS</b></h3>
<!-- Push down content on small screens -->
<div class="w3-hide-large" style="margin-top:83px"></div>

<!-- Top header -->


<!-- Top header -->
<header class="w3-container w3-xlarge">
<p class="w3-right">
<a href="cart.html" i class="fa fa-shopping-cart w3-margin-right"></i></a>
<i class="fa fa-search"></i>
</p>
</header>


<!-- Image header -->
Expand Down
Loading