This repository has been archived by the owner on Jul 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.jsp
executable file
·90 lines (80 loc) · 2.85 KB
/
main.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="java.io.*"%>
<% String result=request.getParameter("RESULT");%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="stylesheet/main.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="script/main.js"></script>
</head>
<body onload="alertlog()">
<%
if(session.getAttribute("Id") == null){
response.sendRedirect("index.jsp");
}%>
<section class="header">
<h1>온라인 상점 시스템</h1>
</section>
<section class="main">
<form id="purchase" action="purchase.jsp" method="POST">
<input type="hidden" name="product" />
</form>
<%
BufferedReader reader = null;
String filePath = application.getRealPath("/Products");
File directory = new File(filePath);
File[] files = directory.listFiles();
if(files != null){
for(File file : files){
String tempFileName = file.getName();
reader = new BufferedReader(new FileReader(filePath + "/" + tempFileName));
String productName = reader.readLine();
String price = reader.readLine();
String stock = reader.readLine();
String imgSrc = reader.readLine();
out.write("<div id='products'>");
out.write("<img src='" + imgSrc + "' alt='can't find img'/>");
out.write("<p>이름 : " + productName + "</p>");
out.write("<p>가격 : " + price + "</p>");
out.write("<p>재고 : " + stock + "</p>");
if(Integer.parseInt(stock) > 0)
out.write("<input type='button' value='구매' onclick=\"Purchase('" + file.getName() + "')\"/>");
else
out.write("<p>구매 불가</p>");
out.write("</div>");
}
}
%>
</section>
<section class="userInfo">
<div>
<p>정보</p>
<%
if(request.getParameter("ptrValue") != "" && request.getParameter("ptrValue") != null){
int addPoint = Integer.parseInt(request.getParameter("ptrValue"));
int point = Integer.parseInt(session.getAttribute("Point").toString());
session.setAttribute("Point", addPoint + point);
%>
<script>
alert("포인트 추가 완료.");
</script><%
}
out.write("<p>아이디 : " + session.getAttribute("Id") + "</p>");
out.write("<p>포인트 : " + session.getAttribute("Point") + "</p>");
%>
<input type="button" value="이용내역 확인" onclick="moveLog()"/><input type="button" value="로그아웃" onclick="logout()"/>
</div><BR>
<div>
<p>포인트 추가</p>
<form id="addPoint" action="main.jsp" method="POST">
<input type="number" name="ptrValue"/><BR>
<input type="submit" value="포인트 추가"/>
</form>
</div>
</section>
<section class="footer">
<p>201402386 이동근</p>
</section>
</body>
</html>