일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- hide
- calc.plus
- 파일질라설치오류
- 1521
- Math.floor()
- excel중복체크
- 증가값
- ctrl+/
- slideUp
- toFixed()
- removeClass
- Math.round()
- selectedIndex
- push오류
- selectoptions
- calc.minus
- Excel
- Parent
- addClass
- Git
- 파일질라설치
- FileZilla설치
- 파일질라다운로드
- 소스트리인증실패
- SUB함수
- FileZilla다운로드
- is_check
- 주석이 먹히지 않을 때
- index %
- Math.ceil()
- Today
- Total
잡동사니에도 사랑을
[21.09.13] HelloServlet - init() / doGet() / destroy() 본문
[21.09.13] HelloServlet - init() / doGet() / destroy()
luvforjunk 2021. 9. 13. 23:05////////HelloServlet
package com.hello;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//@WebServlet("/HelloServlet")
public class HelloServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
public void init(ServletConfig config) throws ServletException {
System.out.println("실행하자마자 제일 먼저 호출되는 함수 - init()");
} // Servlet은 브라우저 결과를 찾을 때 init을 가장 먼저 찾는다
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("클라이언트 요청이 있을 때마다 호출하는 함수 - service()");
response.setContentType("text/html"); // 이제부터 쓰는 모든 문서를 html로 인식해라
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("</head>");
out.println("<body>");
out.println("Hello Servlet!!");
out.println("</body>");
out.println("</html>");
}
@Override
public void destroy() {
System.out.println("서블릿 종료될 때 호출된다 - destroy()");
}
}
////////web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
id="WebApp_ID" version="4.0">
<display-name>helloServlet</display-name>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>com.hello.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/HelloServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
'JAVA_EE > Servlet' 카테고리의 다른 글
[21.09.29] writeForm(memberServlet) (0) | 2021.09.29 |
---|---|
[21.09.28] writeform(memberServlet) (0) | 2021.09.29 |
[21.09.27] writeForm.html (memberServlet) - (0) | 2021.09.27 |
[21.09.27] CalcServlet, input.html, web.xml(testServlet) - (0) | 2021.09.27 |
[21.09.27] ParamServlet, parameter.html, web.xml(testServlet) - (0) | 2021.09.27 |