-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.jsp
More file actions
42 lines (38 loc) · 1.1 KB
/
delete.jsp
File metadata and controls
42 lines (38 loc) · 1.1 KB
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
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ include file="db.jsp"%>
<%
try{
String id = request.getParameter("id");
String password = request.getParameter("password");
String sql = "delete from signup where id = ? and password = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, id);
pstmt.setString(2, password);
pstmt.executeUpdate();
session.removeAttribute("id");
session.removeAttribute("password");
Cookie[] cookies = request.getCookies();
if(cookies != null){
for(Cookie cookie : cookies){
if("id".equals(cookie.getName())){
cookie.setMaxAge(0); // 쿠키 만료
cookie.setPath("/"); // 경로 지정(생성할 때와 동일해야 함)
response.addCookie(cookie);
}
}
}
%>
<script>
alert('회원탈퇴 되었습니다.');
</script>
<%
response.sendRedirect("mainpage.jsp");
} catch(Exception e){
out.print(e);
} finally {
if (pstmt != null) pstmt.close();
if(conn!= null) conn.close();
}
%>