diff --git a/Coursework - Web Application and AI/ecom/database/20210519.sql b/Coursework - Web Application and AI/ecom/database/20210519.sql new file mode 100644 index 0000000..b1b2ddb --- /dev/null +++ b/Coursework - Web Application and AI/ecom/database/20210519.sql @@ -0,0 +1,108 @@ +-- MySQL dump 10.13 Distrib 8.0.22, for Win64 (x86_64) +-- +-- Host: localhost Database: ecommerce_cart +-- ------------------------------------------------------ +-- Server version 8.0.22 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `orders` +-- + +DROP TABLE IF EXISTS `orders`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `orders` ( + `o_id` int NOT NULL AUTO_INCREMENT, + `p_id` int NOT NULL, + `u_id` int NOT NULL, + `o_quantity` int NOT NULL, + `o_date` varchar(450) NOT NULL, + PRIMARY KEY (`o_id`) +) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `orders` +-- + +LOCK TABLES `orders` WRITE; +/*!40000 ALTER TABLE `orders` DISABLE KEYS */; +INSERT INTO `orders` VALUES (25,3,1,3,'2021-05-15'),(26,2,1,1,'2021-05-15'); +/*!40000 ALTER TABLE `orders` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `products` +-- + +DROP TABLE IF EXISTS `products`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `products` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(450) NOT NULL, + `category` varchar(450) NOT NULL, + `price` double NOT NULL, + `image` varchar(450) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `products` +-- + +LOCK TABLES `products` WRITE; +/*!40000 ALTER TABLE `products` DISABLE KEYS */; +INSERT INTO `products` VALUES (1,'New Arrival Femal Shoes','Female Shoes',120,'female-shoes.jpg'),(2,'Ladies Pure PU Shoulder Bag','Ladis Bag',69.99,'ladis-bag.jpg'),(3,'Stylish Men Office Suits','Men Clothes',169,'men-suits.jpg'),(4,'Jaeger-LeCoultre Men Watch','Men Watch',2500.99,'men-watch.jpg'),(5,'FreeMax e-cigarettes VB-456','E-Cigarattes',310,'smoking-e-cigarette.jpg'),(6,'GeekVapee e-cigarattes MM-632','E-Cigarattes',555.5,'smoking-e-cigarette-2.jpg'); +/*!40000 ALTER TABLE `products` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `users` +-- + +DROP TABLE IF EXISTS `users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `users` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(250) NOT NULL, + `email` varchar(250) NOT NULL, + `password` varchar(250) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `email_UNIQUE` (`email`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `users` +-- + +LOCK TABLES `users` WRITE; +/*!40000 ALTER TABLE `users` DISABLE KEYS */; +INSERT INTO `users` VALUES (1,'Almamun','almamun@mail.com','123456'); +/*!40000 ALTER TABLE `users` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2021-05-19 23:00:47 diff --git a/Coursework - Web Application and AI/ecom/pom.xml b/Coursework - Web Application and AI/ecom/pom.xml new file mode 100644 index 0000000..2b7e77c --- /dev/null +++ b/Coursework - Web Application and AI/ecom/pom.xml @@ -0,0 +1,33 @@ + + 4.0.0 + ecom-1 + ecom + 0.0.1-SNAPSHOT + war + + + + + mysql + mysql-connector-java + 8.0.30 + + + + + + + + maven-compiler-plugin + 3.8.1 + + 18 + + + + maven-war-plugin + 3.2.3 + + + + \ No newline at end of file diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/connection/DbCon.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/connection/DbCon.java new file mode 100644 index 0000000..d09e614 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/connection/DbCon.java @@ -0,0 +1,17 @@ +package src.cn.techtutorial.connection; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +public class DbCon { + private static Connection connection = null; + public static Connection getConnection() throws ClassNotFoundException, SQLException{ + if(connection == null){ + Class.forName("com.mysql.cj.jdbc.Driver"); + connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/ecommerce_cart","root","root"); + System.out.print("connected"); + } + return connection; + } +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/dao/OrderDao.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/dao/OrderDao.java new file mode 100644 index 0000000..46b1c89 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/dao/OrderDao.java @@ -0,0 +1,86 @@ +package src.cn.techtutorial.dao; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; + +import src.cn.techtutorial.model.*; + +public class OrderDao { + + private Connection con; + + private String query; + private PreparedStatement pst; + private ResultSet rs; + + + + public OrderDao(Connection con) { + super(); + this.con = con; + } + + public boolean insertOrder(Order model) { + boolean result = false; + try { + query = "insert into orders (p_id, u_id, o_quantity, o_date) values(?,?,?,?)"; + pst = this.con.prepareStatement(query); + pst.setInt(1, model.getId()); + pst.setInt(2, model.getUid()); + pst.setInt(3, model.getQunatity()); + pst.setString(4, model.getDate()); + pst.executeUpdate(); + result = true; + } catch (SQLException e) { + System.out.println(e.getMessage()); + } + return result; + } + + + public List userOrders(int id) { + List list = new ArrayList<>(); + try { + query = "select * from orders where u_id=? order by orders.o_id desc"; + pst = this.con.prepareStatement(query); + pst.setInt(1, id); + rs = pst.executeQuery(); + while (rs.next()) { + Order order = new Order(); + ProductDao productDao = new ProductDao(this.con); + int pId = rs.getInt("p_id"); + Product product = productDao.getSingleProduct(pId); + order.setOrderId(rs.getInt("o_id")); + order.setId(pId); + order.setName(product.getName()); + order.setCategory(product.getCategory()); + order.setPrice(product.getPrice()*rs.getInt("o_quantity")); + order.setQunatity(rs.getInt("o_quantity")); + order.setDate(rs.getString("o_date")); + list.add(order); + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + return list; + } + + public void cancelOrder(int id) { + //boolean result = false; + try { + query = "delete from orders where o_id=?"; + pst = this.con.prepareStatement(query); + pst.setInt(1, id); + pst.execute(); + //result = true; + } catch (SQLException e) { + e.printStackTrace(); + System.out.print(e.getMessage()); + } + //return result; + } +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/dao/ProductDao.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/dao/ProductDao.java new file mode 100644 index 0000000..550bd52 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/dao/ProductDao.java @@ -0,0 +1,128 @@ +package src.cn.techtutorial.dao; + +import java.sql.*; +import java.util.*; + +import src.cn.techtutorial.model.Cart; +//import src.cn.techtutorial.model.Cart; +import src.cn.techtutorial.model.Product; + +public class ProductDao { + private Connection con; + + private String query; + private PreparedStatement pst; + private ResultSet rs; + + + public ProductDao(Connection con) { + super(); + this.con = con; + } + + + public List getAllProducts() { + List book = new ArrayList<>(); + try { + + query = "select * from products"; + pst = this.con.prepareStatement(query); + rs = pst.executeQuery(); + + while (rs.next()) { + Product row = new Product(); + row.setId(rs.getInt("id")); + row.setName(rs.getString("name")); + row.setCategory(rs.getString("category")); + row.setPrice(rs.getDouble("price")); + row.setImage(rs.getString("image")); + + book.add(row); + } + + } catch (SQLException e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + return book; + } + + + public Product getSingleProduct(int id) { + Product row = null; + try { + query = "select * from products where id=? "; + + pst = this.con.prepareStatement(query); + pst.setInt(1, id); + ResultSet rs = pst.executeQuery(); + + while (rs.next()) { + row = new Product(); + row.setId(rs.getInt("id")); + row.setName(rs.getString("name")); + row.setCategory(rs.getString("category")); + row.setPrice(rs.getDouble("price")); + row.setImage(rs.getString("image")); + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + + return row; + } + + public double getTotalCartPrice(ArrayList cartList) { + double sum = 0; + try { + if (cartList.size() > 0) { + for (Cart item : cartList) { + query = "select price from products where id=?"; + pst = this.con.prepareStatement(query); + pst.setInt(1, item.getId()); + rs = pst.executeQuery(); + while (rs.next()) { + sum+=rs.getDouble("price")*item.getQuantity(); + } + + } + } + + } catch (SQLException e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + return sum; + } + + + public List getCartProducts(ArrayList cartList) { + List book = new ArrayList<>(); + try { + if (cartList.size() > 0) { + for (Cart item : cartList) { + query = "select * from products where id=?"; + pst = this.con.prepareStatement(query); + pst.setInt(1, item.getId()); + rs = pst.executeQuery(); + while (rs.next()) { + Cart row = new Cart(); + row.setId(rs.getInt("id")); + row.setName(rs.getString("name")); + row.setCategory(rs.getString("category")); + row.setPrice(rs.getDouble("price")*item.getQuantity()); + row.setQuantity(item.getQuantity()); + book.add(row); + } + + } + } + + } catch (SQLException e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + return book; + } +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/dao/UserDao.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/dao/UserDao.java new file mode 100644 index 0000000..db6ab6e --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/dao/UserDao.java @@ -0,0 +1,36 @@ +package src.cn.techtutorial.dao; + +import java.sql.*; +import src.cn.techtutorial.model.*; + +public class UserDao { + private Connection con; + + private String query; + private PreparedStatement pst; + private ResultSet rs; + + public UserDao(Connection con) { + this.con = con; + } + + public User userLogin(String email, String password) { + User user = null; + try { + query = "select * from users where email=? and password=?"; + pst = this.con.prepareStatement(query); + pst.setString(1, email); + pst.setString(2, password); + rs = pst.executeQuery(); + if(rs.next()){ + user = new User(); + user.setId(rs.getInt("id")); + user.setName(rs.getString("name")); + user.setEmail(rs.getString("email")); + } + } catch (SQLException e) { + System.out.print(e.getMessage()); + } + return user; + } +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/model/Cart.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/model/Cart.java new file mode 100644 index 0000000..25232d2 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/model/Cart.java @@ -0,0 +1,23 @@ +package src.cn.techtutorial.model; + +import src.cn.techtutorial.model.Product; + +public class Cart extends Product{ + private int quantity; + + + + + public Cart() { + } + + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } + +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/model/Order.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/model/Order.java new file mode 100644 index 0000000..8073656 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/model/Order.java @@ -0,0 +1,56 @@ +package src.cn.techtutorial.model; + +import src.cn.techtutorial.model.Product; + +public class Order extends Product{ + private int orderId; + private int uid; + private int qunatity; + private String date; + + public Order() { + } + + public Order(int orderId, int uid, int qunatity, String date) { + super(); + this.orderId = orderId; + this.uid = uid; + this.qunatity = qunatity; + this.date = date; + } + + public Order(int uid, int qunatity, String date) { + super(); + this.uid = uid; + this.qunatity = qunatity; + this.date = date; + } + + public int getOrderId() { + return orderId; + } + public void setOrderId(int orderId) { + this.orderId = orderId; + } + + public int getUid() { + return uid; + } + + public void setUid(int uid) { + this.uid = uid; + } + + public int getQunatity() { + return qunatity; + } + public void setQunatity(int qunatity) { + this.qunatity = qunatity; + } + public String getDate() { + return date; + } + public void setDate(String date) { + this.date = date; + } +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/model/Product.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/model/Product.java new file mode 100644 index 0000000..6517ea7 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/model/Product.java @@ -0,0 +1,72 @@ +package src.cn.techtutorial.model; + +public class Product { + private int id; + private String name; + private String category; + private Double price; + private String image; + + + public Product() { + } + + + public Product(int id, String name, String category, Double price, String image) { + super(); + this.id = id; + this.name = name; + this.category = category; + this.price = price; + this.image = image; + } + + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + @Override + public String toString() { + return "Product [id=" + id + ", name=" + name + ", category=" + category + ", price=" + price + ", image=" + + image + "]"; + } + + +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/model/User.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/model/User.java new file mode 100644 index 0000000..48e8aea --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/model/User.java @@ -0,0 +1,56 @@ +package src.cn.techtutorial.model; + +public class User { + private int id; + private String name; + private String email; + private String password; + + public User() { + } + + public User(int id, String name, String email, String password) { + this.id = id; + this.name = name; + this.email = email; + this.password = password; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public String toString() { + return "User [id=" + id + ", name=" + name + ", email=" + email + ", password=" + password + "]"; + } + +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/AddToCartServlet.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/AddToCartServlet.java new file mode 100644 index 0000000..32208db --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/AddToCartServlet.java @@ -0,0 +1,62 @@ +package src.cn.techtutorial.servlet; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import src.cn.techtutorial.model.*; + +/** + * Servlet implementation class AddToCartServlet + */ +@WebServlet("/add-to-cart") +public class AddToCartServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + + try (PrintWriter out = response.getWriter()) { +// out.print("add to cart servlet"); + + ArrayList cartList = new ArrayList<>(); + int id = Integer.parseInt(request.getParameter("id")); + Cart cm = new Cart(); + cm.setId(id); + cm.setQuantity(1); + HttpSession session = request.getSession(); + ArrayList cart_list = (ArrayList) session.getAttribute("cart-list"); + if (cart_list == null) { + cartList.add(cm); + session.setAttribute("cart-list", cartList); + response.sendRedirect("index.jsp"); + } else { + cartList = cart_list; + + boolean exist = false; + for (Cart c : cart_list) { + if (c.getId() == id) { + exist = true; + out.println("

Item Already in Cart. GO to Cart Page

"); + } + } + + if (!exist) { + cartList.add(cm); + response.sendRedirect("index.jsp"); + } + } + } + } + +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/CancelOrderServlet.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/CancelOrderServlet.java new file mode 100644 index 0000000..8c7cfe1 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/CancelOrderServlet.java @@ -0,0 +1,35 @@ +package src.cn.techtutorial.servlet; + +import java.io.IOException; +import java.io.PrintWriter; +import java.sql.SQLException; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import src.cn.techtutorial.connection.DbCon; +import src.cn.techtutorial.dao.OrderDao; + +@WebServlet("/cancel-order") +public class CancelOrderServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + try(PrintWriter out = response.getWriter()) { + String id = request.getParameter("id"); + if(id != null) { + OrderDao orderDao = new OrderDao(DbCon.getConnection()); + orderDao.cancelOrder(Integer.parseInt(id)); + } + response.sendRedirect("orders.jsp"); + } catch (ClassNotFoundException|SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/CheckOutServlet.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/CheckOutServlet.java new file mode 100644 index 0000000..94a6732 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/CheckOutServlet.java @@ -0,0 +1,65 @@ +package src.cn.techtutorial.servlet; + +import java.io.IOException; +import java.io.PrintWriter; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import src.cn.techtutorial.connection.DbCon; +import src.cn.techtutorial.dao.OrderDao; +import src.cn.techtutorial.model.*; + + +@WebServlet("/cart-check-out") +public class CheckOutServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + try(PrintWriter out = response.getWriter()){ + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + Date date = new Date(); + ArrayList cart_list = (ArrayList) request.getSession().getAttribute("cart-list"); + User auth = (User) request.getSession().getAttribute("auth"); + if(cart_list != null && auth!=null) { + for(Cart c:cart_list) { + Order order = new Order(); + order.setId(c.getId()); + order.setUid(auth.getId()); + order.setQunatity(c.getQuantity()); + order.setDate(formatter.format(date)); + + OrderDao oDao = new OrderDao(DbCon.getConnection()); + boolean result = oDao.insertOrder(order); + if(!result) break; + } + cart_list.clear(); + response.sendRedirect("orders.jsp"); + }else { + if(auth==null) { + response.sendRedirect("login.jsp"); + } + response.sendRedirect("cart.jsp"); + } + } catch (ClassNotFoundException|SQLException e) { + + e.printStackTrace(); + } + } + + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + doGet(request, response); + } + +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/LogoutServlet.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/LogoutServlet.java new file mode 100644 index 0000000..e96e116 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/LogoutServlet.java @@ -0,0 +1,37 @@ +package src.cn.techtutorial.servlet; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Servlet implementation class LogoutServlet + */ +@WebServlet("/log-out") +public class LogoutServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + if(request.getSession().getAttribute("auth")!=null) { + request.getSession().removeAttribute("auth"); + response.sendRedirect("login.jsp"); + }else { + response.sendRedirect("index.jsp"); + } + + } + } + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + doGet(request, response); + } + +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/OrderNowServlet.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/OrderNowServlet.java new file mode 100644 index 0000000..b8de3cd --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/OrderNowServlet.java @@ -0,0 +1,74 @@ +package src.cn.techtutorial.servlet; + +import java.io.IOException; +import java.io.PrintWriter; +import java.sql.SQLException; +import java.util.*; +import java.text.SimpleDateFormat; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import src.cn.techtutorial.connection.DbCon; +import src.cn.techtutorial.dao.*; +import src.cn.techtutorial.model.*; + + +@WebServlet("/order-now") +public class OrderNowServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + Date date = new Date(); + + User auth = (User) request.getSession().getAttribute("auth"); + + if (auth != null) { + String productId = request.getParameter("id"); + int productQuantity = Integer.parseInt(request.getParameter("quantity")); + if (productQuantity <= 0) { + productQuantity = 1; + } + Order orderModel = new Order(); + orderModel.setId(Integer.parseInt(productId)); + orderModel.setUid(auth.getId()); + orderModel.setQunatity(productQuantity); + orderModel.setDate(formatter.format(date)); + + OrderDao orderDao = new OrderDao(DbCon.getConnection()); + boolean result = orderDao.insertOrder(orderModel); + if (result) { + ArrayList cart_list = (ArrayList) request.getSession().getAttribute("cart-list"); + if (cart_list != null) { + for (Cart c : cart_list) { + if (c.getId() == Integer.parseInt(productId)) { + cart_list.remove(cart_list.indexOf(c)); + break; + } + } + } + response.sendRedirect("orders.jsp"); + } else { + out.println("order failed"); + } + } else { + response.sendRedirect("login.jsp"); + } + + } catch (ClassNotFoundException|SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + doGet(request, response); + } + +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/QuantityIncDecServlet.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/QuantityIncDecServlet.java new file mode 100644 index 0000000..b9de0c8 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/QuantityIncDecServlet.java @@ -0,0 +1,57 @@ +package src.cn.techtutorial.servlet; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import src.cn.techtutorial.model.Cart; + +@WebServlet("/quantity-inc-dec") + +public class QuantityIncDecServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + String action = request.getParameter("action"); + int id = Integer.parseInt(request.getParameter("id")); + ArrayList cart_list = (ArrayList) request.getSession().getAttribute("cart-list"); + + if (action != null && id >= 1) { + if (action.equals("inc")) { + for (Cart c : cart_list) { + if (c.getId() == id) { + int quantity = c.getQuantity(); + quantity++; + c.setQuantity(quantity); + response.sendRedirect("cart.jsp"); + } + } + } + + if (action.equals("dec")) { + for (Cart c : cart_list) { + if (c.getId() == id && c.getQuantity() > 1) { + int quantity = c.getQuantity(); + quantity--; + c.setQuantity(quantity); + break; + } + } + response.sendRedirect("cart.jsp"); + } + } else { + response.sendRedirect("cart.jsp"); + } + } + } + +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/RemoveFromCartServlet.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/RemoveFromCartServlet.java new file mode 100644 index 0000000..ee50c58 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/RemoveFromCartServlet.java @@ -0,0 +1,43 @@ +package src.cn.techtutorial.servlet; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import src.cn.techtutorial.model.Cart; + +@WebServlet("/remove-from-cart") +public class RemoveFromCartServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + String bookId = request.getParameter("id"); + if (bookId != null) { + ArrayList cart_list = (ArrayList) request.getSession().getAttribute("cart-list"); + if (cart_list != null) { + for (Cart c : cart_list) { + if (c.getId() == Integer.parseInt(bookId)) { + cart_list.remove(cart_list.indexOf(c)); + break; + } + } + } + response.sendRedirect("cart.jsp"); + + } else { + response.sendRedirect("cart.jsp"); + } + + } + } + +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/loginServlet.java b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/loginServlet.java new file mode 100644 index 0000000..f2f6b47 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/cn/techtutorial/servlet/loginServlet.java @@ -0,0 +1,54 @@ +package src.cn.techtutorial.servlet; + +import java.io.IOException; +import java.io.PrintWriter; +import java.sql.SQLException; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import src.cn.techtutorial.connection.DbCon; +import src.cn.techtutorial.dao.UserDao; +import src.cn.techtutorial.model.User; + +/** + * Servlet implementation class loginServlet + */ +@WebServlet("/user-login") +public class loginServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + response.sendRedirect("login.jsp"); + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + String email = request.getParameter("login-email"); + String password = request.getParameter("login-password"); + + UserDao udao = new UserDao(DbCon.getConnection()); + User user = udao.userLogin(email, password); + if (user != null) { + request.getSession().setAttribute("auth", user); + System.out.print("user logged in"); + response.sendRedirect("index.jsp"); + } else { + out.println("there is no user"); + } + + } catch (ClassNotFoundException|SQLException e) { + e.printStackTrace(); + } + } + +} diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/main/webapp/META-INF/MANIFEST.MF b/Coursework - Web Application and AI/ecom/src/main/java/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000..5e94951 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/Coursework - Web Application and AI/ecom/src/main/java/src/main/webapp/WEB-INF/web.xml b/Coursework - Web Application and AI/ecom/src/main/java/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..85f153e --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/java/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,12 @@ + + + Ecom1 + + index.html + index.jsp + index.htm + default.html + default.jsp + default.htm + + \ No newline at end of file diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/META-INF/MANIFEST.MF b/Coursework - Web Application and AI/ecom/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000..5e94951 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/WEB-INF/web.xml b/Coursework - Web Application and AI/ecom/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..206f6ab --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,12 @@ + + + ecom + + index.html + index.jsp + index.htm + default.html + default.jsp + default.htm + + \ No newline at end of file diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/cart.jsp b/Coursework - Web Application and AI/ecom/src/main/webapp/cart.jsp new file mode 100644 index 0000000..e2d8c31 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/webapp/cart.jsp @@ -0,0 +1,87 @@ +<%@page import="src.cn.techtutorial.connection.DbCon"%> +<%@page import="src.cn.techtutorial.dao.ProductDao"%> +<%@page import="src.cn.techtutorial.model.*"%> +<%@page import="java.util.*"%> +<%@page import="java.text.DecimalFormat"%> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> +<% +DecimalFormat dcf = new DecimalFormat("#.##"); +request.setAttribute("dcf", dcf); +User auth = (User) request.getSession().getAttribute("auth"); +if (auth != null) { + request.setAttribute("person", auth); +} +ArrayList cart_list = (ArrayList) session.getAttribute("cart-list"); +List cartProduct = null; +if (cart_list != null) { + ProductDao pDao = new ProductDao(DbCon.getConnection()); + cartProduct = pDao.getCartProducts(cart_list); + double total = pDao.getTotalCartPrice(cart_list); + request.setAttribute("total", total); + request.setAttribute("cart_list", cart_list); +} +%> + + + +<%@include file="/includes/head.jsp"%> +E-Commerce Cart + + + + <%@include file="/includes/navbar.jsp"%> + +
+

Total Price: £${(total>0)?dcf.format(total):0}

Checkout
+ + + + + + + + + + + + <% + if (cart_list != null) { + for (Cart c : cartProduct) { + %> + + + + + + + + + <% + }}%> + +
NameCategoryPriceQuantity
<%=c.getName()%><%=c.getCategory()%>£<%= dcf.format(c.getPrice())%> +
+ +
+ + + +
+ +
+
Remove
+
+ + <%@include file="/includes/footer.jsp"%> + + \ No newline at end of file diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/includes/footer.jsp b/Coursework - Web Application and AI/ecom/src/main/webapp/includes/footer.jsp new file mode 100644 index 0000000..8beb7f8 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/webapp/includes/footer.jsp @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/includes/head.jsp b/Coursework - Web Application and AI/ecom/src/main/webapp/includes/head.jsp new file mode 100644 index 0000000..0658c56 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/webapp/includes/head.jsp @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/includes/navbar.jsp b/Coursework - Web Application and AI/ecom/src/main/webapp/includes/navbar.jsp new file mode 100644 index 0000000..d7a51c2 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/webapp/includes/navbar.jsp @@ -0,0 +1,41 @@ + + + + \ No newline at end of file diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/index.jsp b/Coursework - Web Application and AI/ecom/src/main/webapp/index.jsp new file mode 100644 index 0000000..e0747be --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/webapp/index.jsp @@ -0,0 +1,70 @@ + +<%@page import="src.cn.techtutorial.connection.DbCon"%> +<%@page import="src.cn.techtutorial.model.*"%> +<%@page import="src.cn.techtutorial.dao.*"%> +<%@page import="java.util.*"%> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + +<% +User auth = (User) request.getSession().getAttribute("auth"); +if (auth != null) { + request.setAttribute("auth", auth); +} + +ProductDao pd = new ProductDao(DbCon.getConnection()); +List products = pd.getAllProducts(); +ArrayList cart_list = (ArrayList) session.getAttribute("cart-list"); +if (cart_list != null) { + request.setAttribute("cart_list", cart_list); +} +%> + + + + + +Computer For You +<%@include file="/includes/head.jsp"%> + + +<%@include file="/includes/navbar.jsp"%> + +
+
All Products
+
+ <% + if (!products.isEmpty()) { + for (Product p : products) { + %> +
+
+ Card image cap +
+
<%=p.getName() %>
+
Price: £<%=p.getPrice() %>
+
Category: <%=p.getCategory() %>
+ +
+
+
+ <% + } + } else { + out.println("There is no product"); + } + %> + +
+
+ + + +<%@include file="/includes/footer.jsp"%> + + \ No newline at end of file diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/login.jsp b/Coursework - Web Application and AI/ecom/src/main/webapp/login.jsp new file mode 100644 index 0000000..fcb3ddc --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/webapp/login.jsp @@ -0,0 +1,44 @@ + +<%@page import="src.cn.techtutorial.connection.DbCon"%> +<%@page import="src.cn.techtutorial.model.*"%> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + +<% +User auth = (User) request.getSession().getAttribute("auth"); +if (auth != null) { + request.setAttribute("auth", auth); +} +%> + + + + +Login +<%@include file="/includes/head.jsp"%> + + +
+
+
User Login
+
+
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+<%@include file="/includes/footer.jsp"%> + + \ No newline at end of file diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/orders.jsp b/Coursework - Web Application and AI/ecom/src/main/webapp/orders.jsp new file mode 100644 index 0000000..7dbf3e6 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/src/main/webapp/orders.jsp @@ -0,0 +1,70 @@ +<%@page import="java.text.DecimalFormat"%> +<%@page import="src.cn.techtutorial.dao.OrderDao"%> +<%@page import="src.cn.techtutorial.connection.DbCon"%> +<%@page import="src.cn.techtutorial.dao.ProductDao"%> +<%@page import="src.cn.techtutorial.model.*"%> +<%@page import="java.util.*"%> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + <% + DecimalFormat dcf = new DecimalFormat("#.##"); + request.setAttribute("dcf", dcf); + User auth = (User) request.getSession().getAttribute("auth"); + List orders = null; + if (auth != null) { + request.setAttribute("auth", auth); + OrderDao orderDao = new OrderDao(DbCon.getConnection()); + orders = orderDao.userOrders(auth.getId()); + }else{ + response.sendRedirect("login.jsp"); + } + ArrayList cart_list = (ArrayList) session.getAttribute("cart-list"); + if (cart_list != null) { + request.setAttribute("cart_list", cart_list); + } + + %> + + + +<%@include file="/includes/head.jsp"%> +E-Commerce Cart + + + <%@include file="/includes/navbar.jsp"%> +
+
All Orders
+ + + + + + + + + + + + + + <% + if(orders != null){ + for(Order o:orders){%> + + + + + + + + + <%} + } + %> + + +
DateNameCategoryQuantityPriceCancel
<%=o.getDate() %><%=o.getName() %><%=o.getCategory() %><%=o.getQunatity() %><%=dcf.format(o.getPrice()) %>Cancel Order
+
+ <%@include file="/includes/footer.jsp"%> + + \ No newline at end of file diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/MOUSE.jpg b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/MOUSE.jpg new file mode 100644 index 0000000..477eb47 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/MOUSE.jpg differ diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/PHOTOS.jpg b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/PHOTOS.jpg new file mode 100644 index 0000000..7973f53 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/PHOTOS.jpg differ diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/POWER.jpg b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/POWER.jpg new file mode 100644 index 0000000..208c09d Binary files /dev/null and b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/POWER.jpg differ diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/PROCESSOR.jpg b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/PROCESSOR.jpg new file mode 100644 index 0000000..46bcf3e Binary files /dev/null and b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/PROCESSOR.jpg differ diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/RAM.jpg b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/RAM.jpg new file mode 100644 index 0000000..d44e7c5 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/RAM.jpg differ diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/SMPS.jpg b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/SMPS.jpg new file mode 100644 index 0000000..9c2febe Binary files /dev/null and b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/SMPS.jpg differ diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/WINDOWS.jpg b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/WINDOWS.jpg new file mode 100644 index 0000000..f2832b9 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/WINDOWS.jpg differ diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/anti.jpg b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/anti.jpg new file mode 100644 index 0000000..8e746d8 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/anti.jpg differ diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/keyboard.jpg b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/keyboard.jpg new file mode 100644 index 0000000..d1b1b1d Binary files /dev/null and b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/keyboard.jpg differ diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/keyboard1.jpg b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/keyboard1.jpg new file mode 100644 index 0000000..6c47949 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/keyboard1.jpg differ diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/motherboard.jpg b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/motherboard.jpg new file mode 100644 index 0000000..851d6cb Binary files /dev/null and b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/motherboard.jpg differ diff --git a/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/order-placed.jpg b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/order-placed.jpg new file mode 100644 index 0000000..fea6241 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/src/main/webapp/product-image/order-placed.jpg differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/connection/DbCon.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/connection/DbCon.class new file mode 100644 index 0000000..ca1d17d Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/connection/DbCon.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/dao/OrderDao.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/dao/OrderDao.class new file mode 100644 index 0000000..cc51486 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/dao/OrderDao.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/dao/ProductDao.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/dao/ProductDao.class new file mode 100644 index 0000000..b48f061 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/dao/ProductDao.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/dao/UserDao.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/dao/UserDao.class new file mode 100644 index 0000000..c673491 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/dao/UserDao.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/model/Cart.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/model/Cart.class new file mode 100644 index 0000000..d623ff7 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/model/Cart.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/model/Order.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/model/Order.class new file mode 100644 index 0000000..a58fa3d Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/model/Order.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/model/Product.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/model/Product.class new file mode 100644 index 0000000..90c504b Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/model/Product.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/model/User.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/model/User.class new file mode 100644 index 0000000..a5d0c38 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/model/User.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/AddToCartServlet.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/AddToCartServlet.class new file mode 100644 index 0000000..8e73931 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/AddToCartServlet.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/CancelOrderServlet.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/CancelOrderServlet.class new file mode 100644 index 0000000..54087c5 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/CancelOrderServlet.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/CheckOutServlet.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/CheckOutServlet.class new file mode 100644 index 0000000..004e16a Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/CheckOutServlet.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/LogoutServlet.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/LogoutServlet.class new file mode 100644 index 0000000..992bd10 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/LogoutServlet.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/OrderNowServlet.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/OrderNowServlet.class new file mode 100644 index 0000000..0e63150 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/OrderNowServlet.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/QuantityIncDecServlet.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/QuantityIncDecServlet.class new file mode 100644 index 0000000..cd77b7f Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/QuantityIncDecServlet.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/RemoveFromCartServlet.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/RemoveFromCartServlet.class new file mode 100644 index 0000000..be17b6d Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/RemoveFromCartServlet.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/loginServlet.class b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/loginServlet.class new file mode 100644 index 0000000..9c26dc7 Binary files /dev/null and b/Coursework - Web Application and AI/ecom/target/classes/src/cn/techtutorial/servlet/loginServlet.class differ diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/main/webapp/META-INF/MANIFEST.MF b/Coursework - Web Application and AI/ecom/target/classes/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000..5e94951 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/target/classes/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/Coursework - Web Application and AI/ecom/target/classes/src/main/webapp/WEB-INF/web.xml b/Coursework - Web Application and AI/ecom/target/classes/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..85f153e --- /dev/null +++ b/Coursework - Web Application and AI/ecom/target/classes/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,12 @@ + + + Ecom1 + + index.html + index.jsp + index.htm + default.html + default.jsp + default.htm + + \ No newline at end of file diff --git a/Coursework - Web Application and AI/ecom/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF b/Coursework - Web Application and AI/ecom/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..ca0356f --- /dev/null +++ b/Coursework - Web Application and AI/ecom/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF @@ -0,0 +1,4 @@ +Manifest-Version: 1.0 +Build-Jdk-Spec: 18 +Created-By: Maven Integration for Eclipse + diff --git a/Coursework - Web Application and AI/ecom/target/m2e-wtp/web-resources/META-INF/maven/ecom-1/ecom/pom.properties b/Coursework - Web Application and AI/ecom/target/m2e-wtp/web-resources/META-INF/maven/ecom-1/ecom/pom.properties new file mode 100644 index 0000000..a2fdd52 --- /dev/null +++ b/Coursework - Web Application and AI/ecom/target/m2e-wtp/web-resources/META-INF/maven/ecom-1/ecom/pom.properties @@ -0,0 +1,7 @@ +#Generated by Maven Integration for Eclipse +#Fri Aug 26 05:23:48 BST 2022 +artifactId=ecom +groupId=ecom-1 +m2e.projectLocation=C\:\\Users\\GALILEO\\eclipse-workspace\\ecom +m2e.projectName=ecom +version=0.0.1-SNAPSHOT diff --git a/Coursework - Web Application and AI/ecom/target/m2e-wtp/web-resources/META-INF/maven/ecom-1/ecom/pom.xml b/Coursework - Web Application and AI/ecom/target/m2e-wtp/web-resources/META-INF/maven/ecom-1/ecom/pom.xml new file mode 100644 index 0000000..2b7e77c --- /dev/null +++ b/Coursework - Web Application and AI/ecom/target/m2e-wtp/web-resources/META-INF/maven/ecom-1/ecom/pom.xml @@ -0,0 +1,33 @@ + + 4.0.0 + ecom-1 + ecom + 0.0.1-SNAPSHOT + war + + + + + mysql + mysql-connector-java + 8.0.30 + + + + + + + + maven-compiler-plugin + 3.8.1 + + 18 + + + + maven-war-plugin + 3.2.3 + + + + \ No newline at end of file