jsp 회원등록,수정,삭제,리스트(CRUD) 로직 구현하기
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
|
}else if(command.equals("/member/memberfindByPwdAction.do")) {
String memberId = request.getParameter("memberid");
System.out.println("memberid"+memberId);
String memberName = request.getParameter("memberName");
System.out.println("memberNmae"+memberName);
// 로직 실행할 객체 새로 생성해줌
MemberDao md = new MemberDao();
//저장할 객체인 VO 에다가 아이디,이름 넣으면 로직 실행되게 만들기
MemberVo mv = md.findByPwd(memberId, memberName);
// 리다이렉트로 보내는 경우니깐 세션값에다가 값을 저장 request 는 서블릿 내에서만 저장하는거라서
HttpSession session = request.getSession();
session.setAttribute("mv", mv);
if(mv != null) {
response.sendRedirect(request.getContextPath()+"/member/memberFindByPwdResult.jsp");
}else {
response.sendRedirect(request.getContextPath()+"/member/memberFindBypwd.jsp");
}
|
cs |
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
|
public MemberVo findByPwd(String memberid,String memberName) { // 아이디랑 ,이름입력하면 로직 실행됨
MemberVo mv = null; // 데이터객체 값 널 여기다가 저장해줄거임
ResultSet rs = null; // 결과값도 널 결과값 실행 위함
String sql = "SELECT memberpwd FROM member WHERE memberid=? and membername=?";
try {
pstmt = conn.prepareStatement(sql);
System.out.println("pstmt"+pstmt);
pstmt.setString(1, memberid);
pstmt.setString(2, memberName);
rs = pstmt.executeQuery();
System.out.println("rs"+rs);
// System.out.println(rs.next());
if(rs.next()) { // 쿼리가 진행하는 동안에
mv = new MemberVo();
//객체생성
mv.setMemberPwd(rs.getString("memberPwd"));
// 찾을 비밀번호 값을 찾아줌
}
} catch (Exception e) {
e.printStackTrace();
}
// System.out.println("mv"+mv);
return mv;
}
|
cs |
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
|
<%@ 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>
<link rel="stylesheet" href="style.css">
<script src="http://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<section class="logo-form">
<h1>비밀번호 찾기</h1>
<form action="<%=request.getContextPath()%>/member/memberfindByPwdAction.do" method="post">
<div class="int-area">
<input type="text" name="memberid" id="id" autocomplete="off" required>
<label for="id">USER ID</label>
</div>
<div class="int-area">
<input type="text" name="memberName" id="pw" autocomplete="off" required>
<label for="id">USER NAME</label>
</div>
<div class="btn-area">
<button id="btn" type="submit">비밀번호 찾기</button>
</div>
</form>
<div class="caption">
<a href="<%=request.getContextPath()%>/member/memberFindByid.do">forgot userid?</a>
</div>
</section>
<!-- java script -->
<script>
let id = $('#id');
let pw = $('#pw');
let btn = $('#btn');
$(btn).on('click',function(){
if($(id).val()==""){
$(id).next("label").addClass("warning");
setTimeout(function(){
$('label').removeClass('warning');
},1500);
}
else if($(pw).val()==""){
$(pw).next("label").addClass("warning");
setTimeout(function(){
$('label').removeClass('warning');
},1500);
}
action = "<%=request.getContextPath()%>/member/memberJoinAction.do";
method = "post";
});
</script>
</body>
</html>
|
cs |
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
91
92
93
94
95
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import = "java.util.*" %>
<%@ page import="damain.*"%>
<%
MemberVo mv =(MemberVo) session.getAttribute("mv");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="style.css">
<script src="http://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<section class="logo-form">
<h1>비밀번호 확인</h1>
<!-- form action="<%//=request.getContextPath()%>/member/findByIdAction.do" method="post" -->
<div class="int-area">
<input type="text" name="membername" id="id" autocomplete="off" required value="<%=mv.getMemberPwd() %>" readonly="readonly" >
</div>
<div class="caption">
<a href="##">forgot password?</a>
</div>
</section>
<!-- java script -->
<script>
let id = $('#id');
let pw = $('#pw');
let btn = $('#btn');
$(btn).on('click',function(){
if($(id).val()==""){
$(id).next("label").addClass("warning");
setTimeout(function(){
$('label').removeClass('warning');
},1500);
}
else if($(pw).val()==""){
$(pw).next("label").addClass("warning");
setTimeout(function(){
$('label').removeClass('warning');
},1500);
}
action = "<%=request.getContextPath()%>/member/memberJoinAction.do";
method = "post";
});
</script>
</body>
</html>
|
cs |
'기존 > 🏀Jsp' 카테고리의 다른 글
[게시판]게시판 컨트롤러 (0) | 2022.05.31 |
---|---|
[JSP] 회원리스트 로직 구현하기 (0) | 2022.05.31 |
[JSP] jsp 회원 아이디 찾기 로직 구현하기 (0) | 2022.05.31 |
[JSP] 회원로그인 로직 구현하기 (0) | 2022.05.31 |
[JSP] jsp 회원가입 로직 구현하기 (0) | 2022.05.31 |