<%@ 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>Insert title here</title>
</head>
<body>
<form action="request01_process.jsp" method="post">
<p> 아이디 : <input type="text" name="id" value="" placeholder="아이디 입력" /></p>
<p> 비밀번호 : <input type="password" name="password" value="" placeholder="비밀번호 입력"/></p>
<p><input type="submit" value="전송"/>
</form>
</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>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String userId = request.getParameter("id");
String userPw = request.getParameter("password");
%>
<p>아이디 : <%=userId %></p>
<p>비밀번호 : <%=userPw %></p>
</body>
</html>
<%@page import="java.util.Enumeration"%>
<%@ 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>Insert title here</title>
</head>
<body>
<%
Enumeration en = request.getHeaderNames();
while(en.hasMoreElements()) {
String headerName = (String) en.nextElement();
String headerValue = request.getHeader(headerName);
%>
<%= headerName %> : <%=headerValue %><br>
<%
}
%>
</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>Insert title here</title>
</head>
<body>
<p>클라이언트 IP : <%=request.getRemoteAddr() %></p>
<p>요청 정보 길이 : <%=request.getContentLength() %></p>
<p>요청 정보 인코딩 : <%=request.getCharacterEncoding() %></p>
<p>요청 정보 콘텐츠 유형 : <%=request.getContentType() %></p>
<p>요청 정보 프로토콜 : <%=request.getProtocol() %></p>
<p>요청 정보 전송 방식 : <%=request.getMethod() %></p>
<p>요청 URI : <%=request.getRequestURI() %></p>
<p>콘텍스트 경로 : <%=request.getContextPath() %></p>
<p>서버 이름 : <%=request.getServerName() %></p>
<p>서버 포트 : <%=request.getServerPort() %></p>
<p>쿼리문 : <%=request.getQueryString() %></p>
</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>Insert title here</title>
</head>
<body>
<form action="response01_process.jsp" method="post">
<p> 아이디 : <input type="text" name="id" /></p>
<p> 비밀번호 : <input type="text" name="password"/> </p>
<p> <input type="submit" value="전송"></p>
</form>
</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>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String userId = request.getParameter("id");
String userPw = request.getParameter("password");
if(userId.equals("관리자") && userPw.equals("1234")) {
response.sendRedirect("response01_success.jsp");
}else{
response.sendRedirect("response01_failed.jsp");
}
%>
</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>Insert title here</title>
</head>
<body>
로그인 성공 했습니다
</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>Insert title here</title>
</head>
<body>
<p>로그인을 실패하였습니다</p>
<p><a href="./response01.jsp">로그인 가기</a></p>
</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>Insert title here</title>
</head>
<body>
<%
response.sendError(404,"요청 페이지를 찾을 수 없습니다");
%>
</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>Insert title here</title>
</head>
<body>
<%
out.println("오늘의 날짜 및 시각 "+"<br>");
out.println(java.util.Calendar.getInstance().getTime());
%>
</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>Insert title here</title>
</head>
<body>
<form action="out02_process.jsp" method="post">
<p> 아이디 : <input type="text" name="id" /> </p>
<p> 비밀번호 : <input type="password" name="password" /> </p>
<p><input type="submit" value="전송"/></p>
</form>
</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>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String userId = request.getParameter("id");
String userPw = request.getParameter("password");
%>
<p> 아이디 : <% out.println(userId); %></p>
<p> 비밀번호 : <% out.println(userPw); %></p>
</body>
</html>
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;
}
public Product getProductById(String productId) {
Product productById = null;
for (int i = 0; i < listOfProducts.size(); i++) {
Product product = listOfProducts.get(i);
if(product != null && product.getProductId() != null && product.getProductId().equals(productId)){
productById = product;
break;
}
}
return productById;
}
}
<%@ 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;
}
.btn {
padding : 10px 5px;
background-color : #696b6a;
color : #fff;
border-radius : 7px;
}
.btn:hover {
background-color : #404040;
}
.btn.btn-secondary {
background-color : #2a9abd;
}
.btn.btn-secondary:hover {
background-color : #0f496b;
}
.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%
}
</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"%>
<%@ 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;
margin: 15px 0;
}
.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>
<p>
<a href="./product.jsp?id=<%=product.getProductId()%>"
class="btn" role="button">상세 정보»</a>
</div>
<%
}
%>
</div>
<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="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>
.content .row {
padding : 30px 0;
}
.content h3, .content p, .content h4 {
margin : 25px 0;
}
.content h3 {
margin-bottom : 5px;
}
.content .description {
margin-top : 5px;
}
.content .badge {
background-color : #f00;
color : #fff;
border-radius : 5px;
}
</style>
</head>
<body>
<jsp:include page="header.jsp" />
<div class="main">
<div class="banner">
<div class="container">
<h1>상품 정보</h1>
</div>
</div>
<%
String id = request.getParameter("id");
Product product = productDAO.getProductById(id);
%>
<div class="content">
<div class="container">
<div class="row">
<h3><%=product.getPname()%></h3>
<p class="description"><%=product.getDescription()%></p>
<p>
<b>상품 코드 : </b><span class="badge"><%=product.getProductId()%></span>
<p>
<b>제조사</b> :
<%=product.getManufacturer()%></p>
<p>
<b>분류</b> :
<%=product.getCategory()%></p>
<p>
<b>재고 수</b> :
<%=product.getUnitInStock()%>
</p>
<h4><%=product.getUnitPrice()%>원</h4>
<p>
<a href="#" class="btn btn-secondary">상품 주문 »</a>
<a href="./products.jsp" class="btn">상품 목록 »</a>
</p>
</div>
<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.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>
<%
response.setIntHeader("Refresh", 5);
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>