■ bbsdelete.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
|
<%@page import="dao.BbsDao"%>
<%@ 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>bbsdelete.jsp</title>
</head>
<body>
<%
int seq = Integer.parseInt( request.getParameter("seq") );
System.out.println("seq:" + seq);
BbsDao dao = BbsDao.getInstance();
boolean isS = dao.deleteBbs(seq);
if(isS){
%>
<script type="text/javascript">
alert("삭제하였습니다");
location.href = 'bbslist.jsp';
</script>
<%
}else{
%>
<script type="text/javascript">
alert("삭제되지 않았습니다");
location.href = 'bbslist.jsp';
</script>
<%
}
%>
</body>
</html>
|
cs |
■ BbsDao.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
|
public boolean deleteBbs(int seq) {
String sql = " UPDATE BBS "
+ " SET DEL=1 "
+ " WHERE SEQ=? ";
Connection conn = null;
PreparedStatement psmt = null;
int count = 0;
try {
conn = DBConnection.getConnection();
System.out.println("1/6 S deleteBbs");
psmt = conn.prepareStatement(sql);
psmt.setInt(1, seq);
System.out.println("2/6 S deleteBbs");
count = psmt.executeUpdate();
System.out.println("3/6 S deleteBbs");
} catch (Exception e) {
System.out.println("fail deleteBbs");
e.printStackTrace();
} finally {
DBClose.close(psmt, conn, null);
}
return count>0?true:false;
}
|
cs |
'Side Project' 카테고리의 다른 글
#08. [Side Project 1] JSP 로그인, 게시판 만들기 (8) :: 글 검색 기능 (0) | 2020.07.30 |
---|---|
#07. [Side Project 1] JSP 로그인, 게시판 만들기 (7) :: 글 수정 (0) | 2020.07.30 |
#05. [Side Project 1] JSP 로그인, 게시판 만들기 (5) :: 글 내용 Detail 자세히 보기 (0) | 2020.07.30 |
#04. [Side Project 1] JSP 로그인, 게시판 만들기 (4) :: 답글, 댓글, (0) | 2020.07.30 |
#03. [Side Project 1] JSP 로그인, 게시판 만들기 (3) :: 글 목록, List, 조회수 (0) | 2020.07.30 |