240102 HTML writeAction.jsp

2024. 1. 3. 19:582023.11.21-2024.05.31

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 import="com.sukgi.dao.BoardDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>이거 서블릿으로 변경하겠습니다.</title>
</head>
<body>
    <!-- 데이터베이스에 값 전달하고 끝. -->
    <%
    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");
    }
    //1이면 올바른 페이지로 이동,
    //0이면 오류 페이지 이동
    /*
    <!-- 액션테그 -->
    <jsp:forward page="./main.jsp"/> 
    <!-- 자바스크립트 -->
    <script type = "text/jacvascript">
        location.href="./main.jsp";
    </script>
    */
    %>
 
    
    
</body>
</html>
cs

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

240102 HTML write.css  (0) 2024.01.03
240102 HTML write.js  (0) 2024.01.03
240102 HTML write.jsp  (0) 2024.01.03
240102 HTML update.jsp  (0) 2024.01.03
240102 HTML detail.jsp  (1) 2024.01.03