DoR@Hee의 끄적끄적

JSP 글 삭제 기능 만들기 본문

개발/WEB개발

JSP 글 삭제 기능 만들기

DoR@Hee 2019. 1. 31. 23:51

VIEW - board_content_view.jsp와 동일


MODEL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    public void board_delete(String bId) {
        Connection con = null;
        PreparedStatement pstmt = null;
        try {
            String query =  "delete from board where bId = ?";
            Class.forName(driver);
            con=DriverManager.getConnection(url, user, password);
            pstmt = con.prepareStatement(query);
            pstmt.setInt(1, Integer.parseInt(bId));
            pstmt.executeUpdate();
        } catch(Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if(pstmt != null) pstmt.close();
                if(con != null) con.close();
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            }
        }
cs

COMMAND 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package com.javalec.ex.command;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import com.javalec.ex.dao.*;
 
public class BDeleteCommand implements BCommand {
    
    public void execute(HttpServletRequest requset,HttpServletResponse respone) {
        String bId = requset.getParameter("bId");
        BDao dao = new BDao();
        
        dao.board_delete(bId);
    }
 
}
 
cs

CONTROLLER

1
2
3
4
        }if(con.equals("/board_delete.do")) {
            command = new BDeleteCommand();
            command.execute(request, response);
            viewPage = "board_list.do";
cs


'개발 > WEB개발' 카테고리의 다른 글

JSP 회원정보 변경 - 비밀번호  (0) 2019.01.31
JSP 조회수 기능 만들기  (0) 2019.01.31
JSP 글 수정 만들기  (0) 2019.01.31
JSP 로그아웃 만들기  (0) 2019.01.31
JSP 글 보기 만들기  (0) 2019.01.31
Comments