<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>header</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
a {
color: #000;
text-decoration: none;
}
header {
background-color: #000;
width: 100%;
padding: 10px 20px;
}
header a {
color: #fff;
font-weight: 700;
}
.container {
width: 90%;
margin: 0 auto;
}
</style>
</head>
<body>
<header>
<div class="container">
<a href="index.jsp">Home</a>
</div>
</header>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>footer</title>
<style>
footer {
width: 100%;
padding: 20px;
}
</style>
</head>
<body>
<footer>
<div class="container">© WebMarket</div>
</footer>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome</title>
<style>
.main {
width: 100%
}
.main .banner {
width: 100%;
height: 300px;
background-color: #d1d1d1;
text-align: center;
line-height: 300px;
}
.main .banner h1 {
font-size: 5vw;
font-weight: 400;
}
.main .content {
width: 100%;
margin: 0 auto;
padding: 10px;
text-align: center;
}
.main .content h3 {
margin: 0 auto;
padding: 20px 0;
font-weight: 100;
}
.main .content p {
margin-bottom: 30px;
}
</style>
<%!String greenting = "웹 쇼핑몰에 오신 것을 환영합니다";
String tagLine = "Welcome to Web Market";%>
</head>
<body>
<jsp:include page="header.jsp" />
<div class="main">
<div class="banner">
<div class="container">
<h1><%=greenting%></h1>
</div>
</div>
<div class="content">
<div class="container">
<h3><%=tagLine%></h3>
<p>
<%
Date day = new Date();
String am_pm;
int hour = day.getHours();
int minute = day.getMinutes();
int second = day.getSeconds();
if (hour / 12 == 0)
am_pm = "AM";
else {
am_pm = "PM";
hour = hour - 12;
}
String CT = hour + ":" + minute + ":" + second + " " + am_pm;
out.println("현재 접속 시각 : " + CT + "\n");
%>
<p>
<hr>
</div>
</div>
</div>
<jsp:include page="footer.jsp" />
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="dto.Product"%>
<jsp:useBean id="productDAO" class="dao.ProductRepository"
scope="session" />
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>상품 목록</title>
<style>
.main {
width: 100%
}
.main .banner {
width: 100%;
height: 300px;
background-color: #d1d1d1;
line-height: 300px;
}
.main .banner h1 {
font-size: 6vw;
font-weight: 100;
}
.main .content {
width: 100%
}
.main .content .row {
display: flex;
justify-content: space-around;
align-items : center;
}
.main .content .row .column {
width: 300px;
display: flex;
flex-direction: column;
justify-content: center;
}
.main .content .row .column h3,
.main .content .row .column p {
text-align : center;
padding : 10px;
}
.main .content .row .column h3 {
font-size : 1.7rem;
font-weight : 400;
}
</style>
<%!String greenting = "상품목록";%>
</head>
<body>
<jsp:include page="header.jsp" />
<div class="main">
<div class="banner">
<div class="container">
<h1><%=greenting%></h1>
</div>
</div>
<div class="content">
<div class="container">
<div class="row">
<%
ArrayList<Product> listOfProduct = productDAO.getAllProducts();
for (int i = 0; i < listOfProduct.size(); i++) {
Product product = listOfProduct.get(i);
%>
<div class="column">
<h3><%=product.getPname()%></h3>
<p><%=product.getDescription()%></p>
<p><%=product.getUnitPrice()%>원</p>
</div>
<%
}
%>
</div>
<hr>
</div>
</div>
</div>
<jsp:include page="footer.jsp" />
</body>
</html>
package dto;
import java.io.Serializable;
public class Product implements Serializable{
private static final long serialCersionUID = -4274700572038677000L;
private String productId; // 상품아이디
private String pname; // 상품명
private Integer unitPrice; // 상품가격
private String description; // 상품설명
private String manufacturer; // 제조사
private String category; // 분류
private long unitInStock; // 재고수
private String condition; // 신상품 or 중고품 or 재생품
public Product() {
super();
}
public Product(String productId, String pname, Integer unitPrice){
this.productId = productId;
this.pname = pname;
this.unitPrice = unitPrice;
}
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getPname() {
return pname;
}
public void setPname(String pname) {
this.pname = pname;
}
public Integer getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(Integer unitPrice) {
this.unitPrice = unitPrice;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getManufacturer() {
return manufacturer;
}
public void setManufacturer(String manufacturer) {
this.manufacturer = manufacturer;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public long getUnitInStock() {
return unitInStock;
}
public void setUnitInStock(long unitInStock) {
this.unitInStock = unitInStock;
}
public String getCondition() {
return condition;
}
public void setCondition(String condition) {
this.condition = condition;
}
public static long getSerialcersionuid() {
return serialCersionUID;
}
}
package dao;
import java.util.ArrayList;
import dto.Product;
public class ProductRepository {
private ArrayList<Product> listOfProducts = new ArrayList<Product>();
public ProductRepository() {
Product phone = new Product("P1234", "iPhone 6s", 800000);
phone.setDescription("4.7-inch, 1334X750 Renina HD display, 8-megapixel iSight Camera");
phone.setCategory("Smart Phone");
phone.setManufacturer("Apple");
phone.setUnitInStock(1000);
phone.setCondition("New");
Product notebook = new Product("P1235", "LG PC 그램", 1500000);
notebook.setDescription("13.3-inch, IPS LED display, 5rd Generation notebook. Inter Core processors");
notebook.setCategory("Notebook");
notebook.setManufacturer("LG");
notebook.setUnitInStock(1000);
notebook.setCondition("Refurbished");
Product tablet = new Product("P1236", "Galaxy Tab S", 900000);
tablet.setDescription("212.8*125.6*6.6mm, Super AMOLEED display, Octa-Core processor");
tablet.setCategory("Tablet");
tablet.setManufacturer("Samsum");
tablet.setUnitInStock(1000);
tablet.setCondition("Old");
listOfProducts.add(phone);
listOfProducts.add(notebook);
listOfProducts.add(tablet);
}
public ArrayList<Product> getAllProducts() {
return listOfProducts;
}
}