Skip to content

Commit

Permalink
회원정보수정 셀렉트하는중 역슬레시가 붙는 에러
Browse files Browse the repository at this point in the history
  • Loading branch information
wlsgu authored and wlsgu committed Sep 1, 2018
1 parent f4aaf09 commit bc42c8c
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 3 deletions.
12 changes: 12 additions & 0 deletions WebContent/account/chk_update.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%@ 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>

</body>
</html>
2 changes: 1 addition & 1 deletion WebContent/account/create.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</head>
<body style="text-align: center;">
<h1> 회 원 가 입 </h1>
<form action="chk_create.jsp" method="get">
<form action="chk_create.jsp" method="post">
<label><b style="color: red">*</b> I D :</label><input type="text" name="id"/><br/><br/>
<label><b style="color: red">*</b> P W :</label><input type="text" name="pass"/><br/><br/>
<label><b style="color: red">*</b> 이름 :</label><input type="text" name="name"/><br/><br/>
Expand Down
5 changes: 3 additions & 2 deletions WebContent/account/home.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

<b><%=access_id %></b> 님 어서오세요!!<br/><br/>

<a href=""><button>회원정보수정</button></a>
<button>로그아웃</button>
<a href="pw_update.jsp"><button>회원정보수정</button></a>
<a href="logout.jsp"><button>로그아웃</button></a>

</body>
</html>
19 changes: 19 additions & 0 deletions WebContent/account/logout.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
System.out.println("접속한 세션:"+session.getId());
session.invalidate(); // 세션종료
System.out.println(session.getId()+"세션종료하였습니다.");
response.sendRedirect("/exer02/index.jsp");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>【Welcome】</title>
</head>
<body>

</body>
</html>
33 changes: 33 additions & 0 deletions WebContent/account/pw_update.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<%@page import="java.util.Map"%>
<%@page import="beans.AccountDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String access_id = (String)session.getAttribute("access_id");
AccountDao acd = new AccountDao();
Map<String,Object> user = acd.getLoginData(access_id); // 로그인한유저정보
String get_id = (String)user.get("id");
String get_pw = (String)user.get("pass");
String get_name = (String)user.get("name");
String get_gender = (String)user.get("gender");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>【Welcome】</title>
</head>
<body style="text-align: center;">
<h1> 회 원 가 입 </h1>
<form action="chk_update.jsp" method="post">
<label><b style="color: red">*</b> I D :</label><input type="text" name="id" value=<%=get_id%>/><br/><br/>
<label><b style="color: red">*</b> P W :</label><input type="text" name="pass" value=<%=get_pw%>/><br/><br/>
<label><b style="color: red">*</b> 이름 :</label><input type="text" name="name" value=<%=get_name%>/><br/><br/>
<label><b style="color: red">*</b> 성별 :</label>
<input type="radio" name="gender" value="M"/>남자
<input type="radio" name="gender" value="F"/>여자<br/><br/>
<button type="submit">가입</button>
</form>

</body>
</html>
33 changes: 33 additions & 0 deletions src/beans/AccountDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,37 @@ public int addLoginData(String login_id, Date date) {
}
}

//4.접속한 아이디 정보 셀렉트 //20180901 수정중
public Map<String, Object> getLoginData(String id){
try {
//1.연결
Connection conn = DriverManager.getConnection(url, user, password);
//2.쿼리문
String sql = "select * from account where id = ?";
//3.쿼리문 준비
PreparedStatement ps = conn.prepareStatement(sql);
//4.데이터추가
ps.setString(1, id);
//5.쿼리문실행
ResultSet rs = ps.executeQuery();
//6.저장할 맵 추가
Map<String,Object> ret;
//6.데이터조회
if(rs.next()) {
ret = new LinkedHashMap<>();
ret.put("id", rs.getString("id"));
ret.put("pass", rs.getString("pass"));
ret.put("name", rs.getString("name"));
ret.put("gender", rs.getString("gender"));
}else {
ret =null;
}
conn.close();
return ret;
}catch(Exception e) {
e.printStackTrace();
return null;
}
}

}

0 comments on commit bc42c8c

Please sign in to comment.