Login.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
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login</title>
</head>
<body>
<center>
<h2>LOGIN</h2>
<hr>
<% session.invalidate(); %>
<form action = "setProduct.jsp" method = "post">
<table >
<tr>
<td> <input type = "text" name = "id"> </td>
<td align = "center" rowspan = "2"> <input type = "submit" name = "btn" value = "Login" > </td>
</tr>
<tr>
<td> <input type = "password" name = "pwd"> </td>
</tr>
</table>
</form>
</center>
</body>
</html>
|
cs |
setProduct.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
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Product</title>
</head>
<body>
<% request.setCharacterEncoding("UTF-8"); %>
<% String id = request.getParameter("id"); %>
<% if(id=="") { %><script> alert("부적합한 ID 입니다.");history.back(); </script><% }%>
<% request.getSession().setAttribute("id", id); %>
<center>
<h2>상품선택</h2>
<hr>
<%= id %>님으로 로그인하셨습니다.
<hr>
<form action = "Add.jsp" method = "post">
<select name = "product">
<option value="사과">사과</option>
<option value="바나나">바나나</option>
<option value="귤">귤</option>
<option value="파인애플">파인애플</option>
<option value="포도">포도</option>
</select>
<input type="submit" name="btn" value="추가"> <br><br>
</form>
<a href="CheckOut.jsp">계산</a>
</center>
</body>
</html>
|
cs |
add.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
|
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Add</title>
</head>
<body>
<% request.setCharacterEncoding("UTF-8"); %>
<% String id = request.getSession().getAttribute("id").toString(); %>
<% String product = request.getParameter("product"); %>
<% ArrayList<String> arr = (ArrayList)(session.getAttribute("arr")); %>
<% if(arr==null) { arr = new ArrayList<String>(); }
arr.add(product);%>
<% session.setAttribute("arr", arr); %>
<center>
<h2>추가 상품 내역</h2>
<hr>
<%=id %>님의 추가 상품 내역입니다.
<hr>
<%for(String i : arr) {
out.println(i); %><br><%
}%>
<script>alert("상품이 추가 되었습니다"); history.back();</script>
</center>
</body>
</html>
|
cs |
Checkout.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
|
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Checkout</title>
</head>
<body>
<% request.setCharacterEncoding("UTF-8"); %>
<% String id = request.getSession().getAttribute("id").toString(); %>
<% ArrayList<String> arr = (ArrayList)(session.getAttribute("arr")); %>
<center>
<h2>계산</h2>
<hr>
<%= id %>님이 선택하신 상품 목록
<hr>
<br>
<%
if(arr==null) {%> 주문하신 상품이 없습니다. <%} else{
for(String i : arr) {
out.println(i);%><br><%
}
}%>
<br>
<hr>
<input type="button" value = "뒤로가기" onClick="history.back()">
<form action="Login.jsp">
<input type="submit" value = "LogOut">
</form>
</center>
</body>
</html>
|
cs |
'Programming > [JSP]' 카테고리의 다른 글
[JSP] template (0) | 2018.04.16 |
---|---|
[JSP][JAVA BEANS] 회원가입 유효성 검사 (2) | 2018.04.16 |
[JSP] 스코프(Scope)란? (0) | 2018.04.12 |
[JSP] get방식의 sendRedirect로 Parameter Value 넘기기 (0) | 2018.04.12 |
[JSP] 에러 처리 (0) | 2018.04.12 |