모델1 게시판 - 글삭제 구현

http://injava.tistory.com/15 방법과의 차이점(장단점)을 학습



boardRemoveForm.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
<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>BOARD REMOVE FORM</title>
</head>
<body>
<%
if(request.getParameter("boardNo"== null) {
    response.sendRedirect(request.getContextPath()+"/board/boardList.jsp");
else {
%>
    <form action="<%=request.getContextPath()%>/board/boardRemoveAction.jsp" method="post">
        <input name="boardNo" value="<%=request.getParameter("boardNo")%>" type="hidden"/>
        <div>비밀번호확인 :</div>
        <div><input name="boardPw" type="password"></div>
        <div>
            <input type="submit" value="삭제"/>
            <input type="reset" value="초기화"/>
        </div>
    </form>
<%    
}
%>
</body>
</html>
cs



boardRemoveAction.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
<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<%@ page import="java.sql.*" %>
<%@ page import="service.*" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>BOARD REMOVE ACTION</title>
</head>
<body>
<%
if(request.getParameter("boardNo"== null || request.getParameter("boardPw"== null) {
    response.sendRedirect(request.getContextPath()+"/board/boardList.jsp");
else {
    int boardNo = Integer.parseInt(request.getParameter("boardNo"));
    System.out.println("boardNo :"+boardNo);
    String boardPw = request.getParameter("boardPw");
    System.out.println("boardPw :"+boardPw);
    Board board = new Board();
    board.setBoardNo(boardNo);
    board.setBoardPw(boardPw);
    
    BoardDao boardDao = new BoardDao();
    
    if(boardDao.deleteBoard(board)==1){
        response.sendRedirect(request.getContextPath()+"/board/boardList.jsp");
    } else {
        response.sendRedirect(request.getContextPath()+"/board/boardRemoveForm.jsp?boardNo="+boardNo);
    }
}
%>
</body>
</html>
cs


+ Recent posts