240102 웹 만들기 ; Write.java

2024. 1. 4. 16:082023.11.21-2024.05.31

 

웹 만들기 ;

(자바스크립트+CSS+HTML)

 

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
46
47
48
49
50
51
package com.sukgi.web;
 
import java.io.IOException;
 
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import com.sukgi.dao.BoardDAO;
 
@WebServlet("/write")
public class Write extends HttpServlet {
    private static final long serialVersionUID = 1L;
 
    public Write() {
        super();
    }
 
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
 
        response.getWriter().append("Served at: ").append(request.getContextPath());
    }
 
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
 
        //doGet(request, response);
        request.setCharacterEncoding("UTF-8");//한글처리
        String title = request.getParameter("title");
        String content = request.getParameter("content");
        //할일 .
        //DAO 호출
        BoardDAO dao = new BoardDAO();
        //int write(title, content);
        int result = dao.write(title, content);
        
        if(result == 1){
            response.sendRedirect("./index.jsp");
        } else{
            response.sendRedirect("./error.jsp");
        }    
        
        //지금은 해당하지 않습니다. 
//        response.setContentType("text/html;charset=UTF-8");
    }
 
}
 
cs

'2023.11.21-2024.05.31' 카테고리의 다른 글

240104 웹 만들기 ; main.html  (1) 2024.01.04
240104 웹 만들기 ; index.html  (1) 2024.01.04
240102 HTML Update.java  (1) 2024.01.04
240102 웹 만들기 ; Test.java  (1) 2024.01.04
240102 HTML Study.java  (1) 2024.01.04