index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<% response.sendRedirect("controller.jsp?action=main"); %>
</body>
</html>
main.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.ArrayList, product.ProductDTO"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>메인</title>
<link rel="stylesheet" type="text/css" href="/mall/css/main.css">
</head>
<body>
<%--
1. 로그인했을때
로그아웃 버튼 / 마이페이지 버튼 / 장바구니 버튼
2. 로그인안했을때
로그인 버튼 / 회원가입 버튼
3. 상품 목록 출력
상품 선택 버튼
4. 상품 검색 버튼
--%>
<% //변수 선언부
ArrayList<ProductDTO> datas = (ArrayList<ProductDTO>)request.getAttribute("datas");
String member_id = (String)session.getAttribute("member_id");
%>
<%
if(member_id != null){
%>
<div id="login-box">
<a href="controller.jsp?action=logout" class="logout-btn">로그아웃</a>
<a href="controller.jsp?action=mypage" class="logout-btn">마이페이지</a>
<a href="controller.jsp?action=cart" class="logout-btn">장바구니</a>
</div>
<%
}
else{
%>
<div id="logout-box">
<form action="controller.jsp" method="POST">
ID <input type="text" placeholder="사용자 ID를 입력해주세요." name="member_id" class="input-id" required> <br>
PASSWORD <input type="password" pattern="^[0-9a-zA-Z]+" name="member_password" class="input-password" placeholder="사용자 PASSWORD를 입력해주세요." required> <br>
<input type="submit" class='login-btn' value="login" name="action"><br>
</form>
<a href="controller.jsp?action=join" class="logout-btn">회원가입</a>
</div>
<%
}
%>
<div class="search-box">
<form action="controller.jsp" >
<select name="product_searchKeyword" class="search-select">
<option value="name"> 상품명
<option value="seller"> 판매자
</select>
<input type="search" name="product_searchContent" placeholder="검색 할 내용을 입력해주세요." class="search-content">
<input type="submit" class="search-btn" value="search" name="action">
</form>
<ul>
<%
if(datas != null){//상품이 없을 수 있기 때문에 작성
for(ProductDTO data:datas){
if(data.getProduct_cnt() <= 0){
out.print(data.getProduct_name() +"<Strong>품절</Strong>");
}
else{
%>
<li><a href="controller.jsp?action=product&product_num=<%=data.getProduct_num()%>">상품명 <%=data.getProduct_name() %> 상품가격 <%=data.getProduct_price() %> 상품개수 <%=data.getProduct_cnt() %> </a></li>
<%
}
}
}
else{
out.print("상품 준비중...");
}
%>
</ul>
</div>
</body>
</html>
mypage.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>마이페이지</title>
<link rel="stylesheet" type="text/css" href="/mall/css/mypage.css">
</head>
<body>
<%--
1. 이름변경 버튼
2. 회원탈퇴 버튼
3. 메인으로 돌아가기 버튼
--%>
<div class="chang-box">
<form action="controller.jsp" method="POST">
<input type="text" name="member_name" placeholder="변경할 이름을 입력해주세요.">
<input type="submit" onclick="checkname();" name="action" value="chang_name">
</form>
</div>
<div class="secession-box">
<a class="secession-btn" href="controller.jsp?action=secession" onclick="checksecession(event);">회원탈퇴</a>
<a class="main-btn" href="controller.jsp?action=main">메인으로 돌아가기</a>
</div>
</body>
<script type="text/javascript">
function checksecession(event) {
if(confirm("정말 회원 탈퇴하실건가요?")){
return true;
}else{
event.preventDefault();
}
}
function checkname() {
if(confirm("정말 변경하시겠습니까?")){
document.querySelector('form').submit();
}else{
return false;
}
}
</script>
</html>
admin.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.ArrayList, product.ProductDTO" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>관리자 페이지</title>
<link rel="stylesheet" type="text/css" href="/mall/css/admin.css">
</head>
<body>
<%--
1. 상품추가 버튼
2. 상품삭제 버튼
--%>
<%
String member_id = (String)session.getAttribute("member_id");
ArrayList<ProductDTO> datas = (ArrayList<ProductDTO>)request.getAttribute("datas");
%>
<div class="product-insert-box">
<form action="controller.jsp" method="POST">
상품명<input type="text" name="product_name" class="product-name" placeholder="상품이름을 입력하세요.">
상품설명<input type="text" name="product_details" class="product-details" placeholder="상품설명을 입력하세요.">
상품개수<input type="number" name="product_cnt" class="product-cnt" placeholder="상품개수를 입력하세요.">
상품가격<input type="number" name="product_price" class="product-price" placeholder="상품가격을 입력하세요.">
<input type="hidden" name="product_seller" class="product-seller" value="<%=member_id%>">
<input type="submit" class="product-insert-btn" name="action" value="pruductinsert">
</form>
</div>
<div class="product-delete-box">
<ol>
<%
if(datas != null){
for(ProductDTO data:datas){
%>
<li>
상품명 <%=data.getProduct_name() %> 상품가격 <%=data.getProduct_price() %> 상품개수 <%=data.getProduct_cnt() %>
<a href="controller.jsp?action=delete&product_num=<%=data.getProduct_num()%>" class="delect-btn">삭제</a>
</li>
<%
}
}
%>
</ol>
</div>
<a class="main-btn" href="controller.jsp?action=main">메인으로 돌아가기</a>
</body>
</html>
728x90
'국비 내용 정리 > 과제' 카테고리의 다른 글
jSP 쇼핑몰 제작(page : controller) (0) | 2024.08.11 |
---|---|
jSP 쇼핑몰 제작(page : cart, join, product) (0) | 2024.08.11 |
jsp를 통해 회원가입 작성하기 2번째 (0) | 2024.08.07 |
jsp를 통해 회원가입 작성하기 (0) | 2024.08.06 |
[과제] 미디어쿼리 사용 반응형 웹 (0) | 2024.08.05 |