240102 HTML Study.java

2024. 1. 4. 16:072023.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.sukgi.web;
 
import java.io.IOException;
import java.io.PrintWriter;
 
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
 
@WebServlet("/study")
public class Study extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
   
    public Study() {
        super();
        
    }
 
    
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    
        //response.getWriter().append("Served at: ").append(request.getContextPath());
        String str = "sukgi";
        
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter pw = response.getWriter();
        pw.println("<html>");
        pw.println("<head>");
        pw.println("<title>타이틀입니다.</title>");
        pw.println("</head>");
        pw.println("<body>");
        pw.println("<h1>서블릿이 호출되었습니다.</h1>");
        pw.println("<img src=\"\">");        
        pw.println("당신의 이름은 +str + <br> ");        
        pw.println("이렇게 작업해야 해요. 너무 힘들다 진쨔앙<br> ");
        pw.println("수정하려면 다시 컴파일 해서 실해야해 해요.<br> ");
        pw.println("이것보다 jsp가 조금 더 편합니다. 아닝 더 편하댜아아아<br> ");
        pw.println("<a href=\" ./main.jsp\">main</a>");
        pw.println("</body>");
        pw.println("</html>");
    }
 
    
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    
        doGet(request, response);
    }
 
}
 
/*
 * 
 * 
 * request : 클라이언트가 서버에 요청하는 것.
 * response : 서버가 클라이언트의 요청에 응답하는 것.
 * 
 * 
 * get방식 : 오픈 , url 뒤에 요청 정보를 붙여 보내는 방식
 *                url의 물음표(?) 뒷부분, url 주소에 공개되어 있음.
 * 
 * 
 * 
 * post 방식 : 숨김, url은 그대로이지만, http 바디에 요청 정보를 숨겨서 보냄.
 *             get과 다르게 url 뒤에 부수적인 내용이 없음.
 *  
 *  
 * 
 * */
 
 
cs

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

240102 HTML Update.java  (1) 2024.01.04
240102 웹 만들기 ; Test.java  (1) 2024.01.04
240102 HTML Delete.java  (1) 2024.01.04
240102 HTML DBConnection.java  (1) 2024.01.04
240102 HTML BoardDAO.java  (0) 2024.01.03