티스토리 뷰

 

 

cart.jsp 추가

<div class="container">
		<div class="row">
			<table width="100%">
				<tr>
					<td align="left"><a href="./deletecart.jsp?cartid=<%=cartid %>" class="btn btn-danger">삭제하기</a></td>
					<td align="right"><a href="./shippinginfo.jsp?cartid=<%=cartid %>" class="btn btn-success">주문하기</a></td>
				</tr>	
			</table>
		</div>

 

 

shippinginfo.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<meta charset="UTF-8">
<title>배송 정보</title>
</head>
<body>
	<jsp:include page="menu.jsp" />
	<div class="jumbotron">
		<div class="container">
			<h1 class="display-3">배송 정보</h1>
		</div>
	</div>
	<div class="container">
		<form action="./processshippinginfo.jsp" class="form-horizontal" method="post">
			<input type="hidden" name="cartid" value="<%=request.getParameter("cartid") %>"/>
				<div class="form-group row">
					<label class="col-sm-2">성명</label>
					<div class="col-sm-3">
						<input name="name" type="text" class="form-control" />
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-2">배송일</label>
					<div class="col-sm-3">
						<input name="shippingdate" type="text" class="form-control" />(yyyy/mm/dd)
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-2">국가명</label>
					<div class="col-sm-3">
						<input name="country" type="text" class="form-control" />
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-2">우편번호</label>
					<div class="col-sm-3">
						<input name="zipcode" type="text" class="form-control" />
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-2">주소</label>
					<div class="col-sm-3">
						<input name="addressname" type="text" class="form-control" />
					</div>
				</div>
				<div class="form-group row">
					<div class="col-sm-offset-2 col-sm-10">
						<a href="./cart.jsp?cartid=<%=request.getParameter("cartid") %>" class="btn bnt-secondary" role="button">이전</a>
						<input type="submit" class="btn btn-primary" value="등록" />
						<a href="./checkoutcancelled.jsp" class="btn btn-secondary" role="button">취소</a>
					</div>
				</div>
		</form>
	</div>
</body>
</html>

 

 

processshippinginfo.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.net.URLEncoder" %>    
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		request.setCharacterEncoding("UTF-8");
	
		Cookie cartid = new Cookie("shipping_cartid", URLEncoder.encode(request.getParameter("cartid"),"utf-8"));
		Cookie name = new Cookie("shipping_name", URLEncoder.encode(request.getParameter("name"),"utf-8"));
		Cookie shippingdate = new Cookie("shipping_shippingdate",URLEncoder.encode(request.getParameter("shippingdate"),"utf-8"));
		Cookie country = new Cookie("shipping_country", URLEncoder.encode(request.getParameter("country"),"utf-8"));
		Cookie zipcode = new Cookie("shipping_zipcode", URLEncoder.encode(request.getParameter("zipcode"),"utf-8"));
		Cookie addressname = new Cookie("shipping_addressname", URLEncoder.encode(request.getParameter("addressname"),"utf-8"));
		
		cartid.setMaxAge(24*60*60);
		name.setMaxAge(24*60*60);
		shippingdate.setMaxAge(24*60*60);
		country.setMaxAge(24*60*60);
		zipcode.setMaxAge(24*60*60);
		addressname.setMaxAge(24*60*60);
		
		response.addCookie(cartid);
		response.addCookie(name);
		response.addCookie(shippingdate);
		response.addCookie(country);
		response.addCookie(zipcode);
		response.addCookie(addressname);
		
		response.sendRedirect("orderconfirmation.jsp");
	%>
</body>
</html>

 

 

orderconfirmation.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.net.URLDecoder" %>   
<%@ page import="dto.product" %>
<%@ page import="dao.productrepository" %> 
<!DOCTYPE html>
	<%
		request.setCharacterEncoding("UTF-8");
		
		String cartid = session.getId();
		
		String shipping_cartid = "";
		String shipping_name = "";
		String shipping_shippingdate = "";
		String shipping_country = "";
		String shipping_zipcode = "";
		String shipping_addressname = "";
		
		Cookie[] cookies = request.getCookies();
		
		if(cookies != null){
			for(int i=0; i<cookies.length; i++){
				Cookie thiscookie = cookies[i];
				String n = thiscookie.getName();
				if(n.equals("shipping_cartid")){
					shipping_cartid = URLDecoder.decode((thiscookie.getValue()),"utf-8");
				}
				if(n.equals("shipping_name")){
					shipping_name = URLDecoder.decode((thiscookie.getValue()),"utf-8");
				}
				if(n.equals("shipping_shippingdate")){
					shipping_shippingdate = URLDecoder.decode((thiscookie.getValue()),"utf-8");
				}
				if(n.equals("shipping_country")){
					shipping_country = URLDecoder.decode((thiscookie.getValue()),"utf-8");
				}
				if(n.equals("shipping_zipcode")){
					shipping_zipcode = URLDecoder.decode((thiscookie.getValue()),"utf-8");
				}
				if(n.equals("shipping_addressname")){
					shipping_addressname = URLDecoder.decode((thiscookie.getValue()),"utf-8");
				}
			}
		}
	%>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<meta charset="UTF-8">
<title>주문 정보</title>
</head>
<body>
	<jsp:include page="menu.jsp"/>
	<div class="jumbotron">
		<div class="container">
			<h1 class="display-3">주문 정보</h1>
		</div>
	</div>
	
	<div class="container col-8 alert alert-info">
		<div class="text-center">
			<h1>영수증</h1>
		</div>
		<div class="row justify-content-between">
			<div class="col-4" align="left">
				<strong>배송 주소</strong><br> 성명 : <%out.println(shipping_name); %><br> 우편번호 : <%out.println(shipping_zipcode); %> 주소 : <%out.println(shipping_addressname); %>(<%out.println(shipping_country); %>) <br>
			</div>
			<div class="col-4" align="right">
				<p> <em>배송일 : <% out.println(shipping_shippingdate); %></em>
			</div>
		</div>
		<div>
			<table class="table table-hover">
			<tr>
				<th class="text-center">도서</th>	
				<th class="text-center">#</th>
				<th class="text-center">자격</th>
				<th class="text-center">소계</th>
			</tr>	
			<%
				int sum=0;
				ArrayList<product> cartlist = (ArrayList<product>)session.getAttribute("cartlist");
				if(cartlist==null){
					cartlist = new ArrayList<product>();
				}
				for(int i=0; i<cartlist.size(); i++){
					product product = cartlist.get(i);
					int total = product.getUnitprice()*product.getQuantity();
					sum = sum+total;
				
			%>
			<tr>
				<td class="text-center"><em><%=product.getPname() %></em></td>
				<td class="text-center"><%=product.getQuantity() %></td>
				<td class="text-center"><%=product.getUnitprice() %>원</td>
				<td class="text-center"><%=total %>원</td>
			</tr>
			<%
				}
			%>	
			<tr>
				<td></td>
				<td></td>
				<td class="text-right"><strong>총액 : </strong></td>
				<td class="text-center text-danger"><strong><%=sum %></strong></td>
			</tr>	
			</table>
			
			<a href="./shippinginfo.jsp?cartid=<%=shipping_cartid %>" class="btn btn-secondary" role="button">이전</a>
			<a href="./thankcustomer.jsp" class="btn btn-success" role="button">주문 완료</a>
			<a href="./checkoutcancelled.jsp" class="btn btn-secondary" role="button">취소</a>
		</div>
	</div>
</body>
</html>

 

 

thankcustomer.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.net.URLDecoder" %>    
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<meta charset="UTF-8">
<title>주문 완료</title>
</head>
<body>
	<%
		String shipping_cartid = "";
		String shipping_name = "";
		String shipping_shippingdate = "";
		String shipping_country = "";
		String shipping_zipcode = "";
		String shipping_addressname = "";
		
		Cookie[] cookies = request.getCookies();
		
		if(cookies != null){
			for(int i=0; i<cookies.length; i++){
				Cookie thiscookie = cookies[i];
				String n = thiscookie.getName();
				if(n.equals("shipping_cartid")){
					shipping_cartid = URLDecoder.decode((thiscookie.getValue()),"utf-8");
				}
				if(n.equals("shipping_shippingdate")){
					shipping_shippingdate = URLDecoder.decode((thiscookie.getValue()),"utf-8");
				}
			}
		}
	%>
	<jsp:include page="menu.jsp" />
	<div class="jumbotron">
		<div class="container">
			<h1 class="display-3">주문 완료</h1>
		</div>
	</div>
	<div class="container">
		<h2 class="alert alert-danger">주문해주셔서 감사합니다.</h2>
		<p> 주문은 <% out.println(shipping_shippingdate); %>에 배송될 예정입니다.
		<p> 주문번호 : <% out.println(shipping_cartid); %>
	</div>
	<div class="container">
		<p> <a href="./products.jsp" class="btn btn-secondary">&laquo; 상품목록</a>
	</div>
</body>
</html>
<%
	session.invalidate();
	
	for(int i=0; i<cookies.length; i++){
		Cookie thiscookie = cookies[i];
		String n = thiscookie.getName();
		if(n.equals("shipping_cartid")){
			thiscookie.setMaxAge(0);
		}
		if(n.equals("shipping_name")){
			thiscookie.setMaxAge(0);
		}
		if(n.equals("shipping_shippingdate")){
			thiscookie.setMaxAge(0);
		}
		if(n.equals("shipping_country")){
			thiscookie.setMaxAge(0);
		}
		if(n.equals("shipping_zipcode")){
			thiscookie.setMaxAge(0);
		}
		if(n.equals("shipping_addressname")){
			thiscookie.setMaxAge(0);
		}
		response.addCookie(thiscookie);
	}
%>

 

 

checkoutcancelled.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<meta charset="UTF-8">
<title>주문 취소</title>
</head>
<body>
	<jsp:include page="menu.jsp"/>
	<div class="jumbotron">
		<div class="container">
			<h1 class="display-3">주문 취소</h1>
		</div>
	</div>
	<div class="container">
		<h2 class="alert alert-danger">주문이 취소되었습니다.</h2>
	</div>
	<div class="container">
		<p><a href="./products.jsp" class="btn btn-secondary">&laquo; 상품 목록</a>
	</div>
</body>
</html>

 

 

주문 완료

 

 

주문 취소

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday