Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
7051CEM_11779852_AttikoOmotayoOladimeji/src/main/webapp/index.jsp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
107 lines (73 sloc)
3.51 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%-- | |
Document : index | |
Created on : 13 Aug 2022, 23:19:17 | |
Author : oladimeji | |
--%> | |
<%@page import="java.util.ArrayList"%> | |
<%@page import="com.ecommerce.loginpack.model.Cart"%> | |
<%@page import="com.ecommerce.loginpack.model.Product"%> | |
<%@page import="java.util.List"%> | |
<%@page import="com.ecommerce.dao.ProductDao"%> | |
<%@page import="com.ecommerce.loginpack.model.UserModelClass"%> | |
<%@page import="com.ecommerce.connection.DbConnection"%> | |
<%@page contentType="text/html" pageEncoding="UTF-8"%> | |
<% | |
UserModelClass auth = (UserModelClass) request.getSession().getAttribute("auth"); | |
if (auth != null) { | |
request.setAttribute("auth", auth); | |
} | |
ProductDao pd = new ProductDao(DbConnection.getConnection()); | |
List<Product> products = pd.getAllProducts(); | |
ArrayList<Cart> cart_list = (ArrayList<Cart>) session.getAttribute("cart-list"); | |
if(cart_list !=null){ | |
request.setAttribute("cart_list", cart_list); | |
} | |
%> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<title>JSP Page</title> | |
<!-- CSS only --> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css"> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css"> | |
</head> | |
<body> | |
<ul> | |
<li><a href="index.jsp"><i class="fa fa-fw fa-home"></i>Home</a></li> | |
<li><a href="login.jsp"><i class="fa fa-fw fa-user"></i>Log-in</a></li> | |
<li><a href="register.jsp"><i class="fa-solid fa-user-plus"></i>Sign-up</a></li> | |
<li><a href="orders.jsp">orders</a></li> | |
<li><a href="cart.jsp"><i class="fa-solid fa-cart-arrow-down"></i>Cart<span class="badge bg-danger px-2">${cart_list.size()}</span></a></li> | |
</ul> | |
<div class="container"> | |
<div class="card-header">All Products</div> | |
<div class="row"> | |
<% | |
if (!products.isEmpty()) { | |
for (Product p : products) {%> | |
<div class="col -sm-6 my-3"> | |
<div class="card" style="width: 20rem;"> | |
<img class ="card-img-top" src="product-images/<%= p.getImage()%>" alt="Card image cap"> | |
<div class="card-body"> | |
<h5 class="card-title"><%= p.getName()%></h5> | |
<h6 class="price">Price: £<%=p.getPrice()%></h6><!-- comment --> | |
<h6 class="category">Category: <%= p.getCategory()%></h6> | |
<div class="mt-3 d-flex justify-content-between"> | |
<a href="add-to-cart?id=<%= p.getProductid()%>" class="btn btn-primary">Add To Cart</a> | |
<a href="order-now?quantity=1&id=<%=p.getProductid()%>" class="btn btn-success">Buy Now</a> | |
</div> | |
</div> | |
</div> | |
<%} | |
} | |
%> | |
</div> | |
</div> | |
</div> | |
<%--<% out.print(DbConnection.getConnection()); %> --%> | |
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.5/dist/umd/popper.min.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.min.js"></script> | |
</body> | |
</html> | |