19.05.19 jsp 쇼핑몰 차량 구매하기 (동영상 64강~65강)
Back-End/JSP 2019. 5. 19. 17:39쇼핑몰 차량 구매하기 기능 구현
Top.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 |
<%@ 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>
<body>
<!-- 세션을 이용한 로그인 처리 -->
<!-- 세션으로 받아온 값은 오브젝트 타입이기 때문에 String 타입으로 컨버팅 한다. -->
<%
String id = (String) session.getAttribute("id");
//로그인이 되어있지 않다면 id에 "GUEST"값을 준다
if (id == null) {
id = "GUEST";
}
%>
<table width="1000" bordercolor="white">
<tr height="70">
<td colspan="4"><a href="RentcarMain.jsp"
style="text-decoration: none"> <!-- 이미지를 불러오기위한 태그 작성 --> <img
alt="" src="img/RENT.jpg" height="150" width="250">
</a></td>
<td align="center" width="200"><%=id%> 님 <%
if(id.equals("GUEST")){ %>
<button onclick="RentcarMain.jsp?center=MemberLogin.jsp">
로그인</button> <%
}
%></td>
</tr>
<!-- 글자를 누르면 화면이 넘어갈수 있도록 a태그를 걸어줌 -->
<tr height="50">
<td align="center" width="200" bgcolor="pink"><font
color="white" size="5"> <a
href="RentcarMain.jsp?center=CarReserveMain.jsp"
style="text-decoration: none"> 예 약 하 기 </a></font></td>
<td align="center" width="200" bgcolor="pink">
<!-- 글자를 누르면 화면이 넘어갈수 있도록 a태그를 걸어줌 --> <font color="white" size="5"><a
href="#" style="text-decoration: none"> 예 약 확 인</a></font>
</td>
<td align="center" width="200" bgcolor="pink">
<!-- 글자를 누르면 화면이 넘어갈수 있도록 a태그를 걸어줌 --> <font color="white" size="5"><a
href="#" style="text-decoration: none"> 자 유 게 시 판 </a></font>
</td>
<td align="center" width="200" bgcolor="pink">
<!-- 글자를 누르면 화면이 넘어갈수 있도록 a태그를 걸어줌 --> <font color="white" size="5"><a
href="#" style="text-decoration: none"> 이 벤 트 </a></font>
</td>
<td align="center" width="200" bgcolor="pink">
<!-- 글자를 누르면 화면이 넘어갈수 있도록 a태그를 걸어줌 --> <font color="white" size="5"><a
href="#" style="text-decoration: none"> 고 객 센 터 </a></font>
</td>
</tr>
</table>
</body>
</html>
|
cs |
CarReserveResult.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 |
<%@ 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>Insert title here</title>
</head>
<body>
<!-- 한글이 넘어올수도 있기 때문에 문자셋설정을 다시한다. -->
<%
request.setCharacterEncoding("euc-kr");
%>
<!-- 한번에 빈클래스에 있는 값들을 받아야되서 useBean 사용 -->
<jsp:useBean id="rbean" class="db.CarReserveBean">
<jsp:setProperty name="rbean" property="*" />
</jsp:useBean>
<%
//로그인한 아이디가 페이지가 변경되어도 유지가 되어야하기 때문에 세션으로 받는다.
//받는 아이디는 오브젝트 타입이기 때문에 String 타입으로 타입변환을 시켜준다.
String id = (String)session.getAttribute("id");
//null값과 비교할시에는 GUEST값이 나와버리므로
//null 대신에 GUEST와 비교한다.
//비교한후에 참이면 (로그인이 안되었으면) 로그인페이지로 이동하게함
if(id==null)
{
%>
<script>//예약할시에 로그인이 안되어있을경우 출력되는 메시지
alert("로그인후 예약이 가능합니다.");
</script>
<%
response.sendRedirect("RentcarMain.jsp?center=MemberLogin.jsp");
}
%>
</body>
</html> |
cs |
CarOptionSelect.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 |
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<html>
<body>
<%
int no = Integer.parseInt(request.getParameter("no"));
//차량 수량
int qty = Integer.parseInt(request.getParameter("qty"));
//이미지를 가져옴
String img = request.getParameter("img");
%>
<div style="text-align: center;">
<form action="RentcarMain.jsp?center=CarReserveResult.jsp"
method="post">
<table width="1000">
<tr height="100">
<td align="center" colspan="3"><font size="6" color="gray">
옵션 선택 </font></td>
</tr>
<tr>
<!-- colspan은 가로셀끼리 병합하는 것이고, rowspan은 세로 셀끼리 병합하는 것 -->
<!-- 차량 사진 옆에 정보들이 떠야하기때문에 세로병합인 rowspan을 사용 -->
<td rowspan="7" width="500" align="center"><img alt=""
src="img/<%=img %>" width="450"></td>
<td width="250" align="center">대여기간</td>
<td width="250" align="center"><select name="dday">
<option value="1">1일</option>
<option value="2">2일</option>
<option value="3">3일</option>
<option value="4">4일</option>
<option value="5">5일</option>
<option value="6">6일</option>
<option value="7">7일</option>
</select></td>
</tr>
<tr>
<td width="250" align="center">대여일</td>
<td width="250" align="center"><input type="date" name="rday"
size="15"></td>
<tr>
<td width="250" align="center">보험적용</td>
<td width="250" align="center"><select name="usein">
<option value="1">적용 (1일 1만원)</option>
<option value="2">미적용</option>
</select></td>
</tr>
<tr>
<td width="250" align="center">wifi 적용</td>
<td width="250" align="center"><select name="usewifi">
<option value="1">적용 (1일 1만원)</option>
<option value="2">미적용</option>
</select></td>
</tr>
<tr>
<td width="250" align="center">네비게이션 적용</td>
<td width="250" align="center"><select name="usenavi">
<option value="1">적용 (무료)</option>
<option value="2">미적용</option>
</select></td>
</tr>
<tr>
<td width="250" align="center">베이비시트 적용</td>
<td width="250" align="center"><select name="useseat">
<option value="1">적용 (1일 1만원)</option>
<option value="2">미적용</option>
</select></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="hidden" name="no"
value="<%=no %>"> <input type="hidden" name="qty"
value="<%=qty %>"> <input type="submit" value="차량예약하기"></td>
</tr>
</table>
</form>
</div>
</body>
</html> |
cs |
CarReserveBean.java (차량 옵션 선택 빈 클래스)
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 |
package db;
public class CarReserveBean {
private int no;
private int qty;
private int dday; //대여기간
private String rday; //대여일은 date타입으로 받았지만 넘겨줄때 String타입으로 변하므로 String타입으로 해야함
private int usein;
private int usewifi;
private int usenavi;
private int useseat;
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public int getQty() {
return qty;
}
public void setQty(int qty) {
this.qty = qty;
}
public int getDday() {
return dday;
}
public void setDday(int dday) {
this.dday = dday;
}
public String getRday() {
return rday;
}
public void setRday(String rday) {
this.rday = rday;
}
public int getUsein() {
return usein;
}
public void setUsein(int usein) {
this.usein = usein;
}
public int getUsewifi() {
return usewifi;
}
public void setUsewifi(int usewifi) {
this.usewifi = usewifi;
}
public int getUsenavi() {
return usenavi;
}
public void setUsenavi(int usenavi) {
this.usenavi = usenavi;
}
public int getUseseat() {
return useseat;
}
public void setUseseat(int useseat) {
this.useseat = useseat;
}
}
|
cs |
'Back-End > JSP' 카테고리의 다른 글
19.05.19 jsp 쇼핑몰 차량 날짜 처리 (동영상 67강) (0) | 2019.05.19 |
---|---|
19.05.19 jsp 쇼핑몰 로그인 (동영상 66강) (0) | 2019.05.19 |
19.05.18 jsp 쇼핑몰 차량 상세보기 (동영상 63강) (0) | 2019.05.18 |
19.05.18 jsp 쇼핑몰 차량 전체보기 (동영상 62강) (0) | 2019.05.18 |
19.05.18 JSP 쇼핑몰 차량 검색하기 (동영상 61강) (0) | 2019.05.18 |