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_Web_Applications_and_AI/WebContent/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.
executable file
72 lines (64 sloc)
1.87 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
<%@page import="cfy.connection.DbCon"%> | |
<%@page import="cfy.dao.ProductDao"%> | |
<%@page import="cfy.model.*"%> | |
<%@page import="java.util.*"%> | |
<%@page import="java.util.List"%> | |
<%@ 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("person", auth); | |
} | |
if(auth.getType().equals("admin")){ | |
response.sendRedirect("admin"); | |
} | |
ProductDao pd = new ProductDao(DbCon.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> | |
<%@include file="/includes/head.jsp"%> | |
<title>Computer For You</title> | |
</head> | |
<body> | |
<%@include file="/includes/navbar.jsp"%> | |
<div class="container"> | |
<div class="card-header my-3">All Products</div> | |
<div class="row"> | |
<% | |
if (!products.isEmpty()) { | |
for (Product p : products) { | |
%> | |
<div class="col-md-3 my-3"> | |
<div class="card w-100"> | |
<img class="card-img-top" src="product-image/<%=p.getImage() %>" | |
alt="Card image cap"> | |
<div class="card-body"> | |
<h5 class="card-title"><%=p.getName() %></h5> | |
<h6 class="price">Price: $<%=p.getPrice() %></h6> | |
<h6 class="category">Category: <%=p.getCategory() %></h6> | |
<h6 class="details">Details: <%=p.getDetails() %></h6> | |
<div class="mt-3 d-flex justify-content-between"> | |
<a class="btn btn-dark" href="add-to-cart?id=<%=p.getId()%>">Add to Cart</a> <a | |
class="btn btn-primary" href="order-now?quantity=1&id=<%=p.getId()%>">Buy Now</a> | |
</div> | |
</div> | |
</div> | |
</div> | |
<% | |
} | |
} else { | |
out.println("There is no proucts"); | |
} | |
%> | |
</div> | |
</div> | |
<%@include file="/includes/footer.jsp"%> | |
</body> | |
</html> |