Christmas Pikachu Servlet Life-Cycle(서블릿 생명주기)
개발일지/JSP

Servlet Life-Cycle(서블릿 생명주기)

ZI_CO 2022. 11. 24.

Servlet_Life-Cycle.pdf
0.15MB

사용자의 요청에 의해서 생성된 Sevelt 생명 주기(생성,실행, 종료) 까지

 

 

 

서블릿 준비 단계

init - 처음 생성되는 과정 

service - 일하는 단계

destory - 종료하는 단계

서블릿 종료 단계

 

 

 

 

package com.boot.lifecycle;

import java.io.IOException;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
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("/ms1")
public class MServlet1 extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@PostConstruct
	public void PostConstruct() {
		System.out.println(">>>PostConstruct<<<");
	}

	@Override
	public void init() throws ServletException {
		System.out.println(">>>init<<<");

	}

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println(">>>service<<<");
	}

	@Override
	public void destroy() {
		System.out.println(">>>destroy<<<");
	}

	@PreDestroy
	public void preDestory() {
		System.out.println(">>>preDestory<<<");

	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println(">>>doGet<<<");
    
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println(">>>doPost<<<");

	}

}

'개발일지 > JSP' 카테고리의 다른 글

Servlet JSP 스크립트  (0) 2022.11.24
Servlet form 데이터 처리  (0) 2022.11.24
Servlet - reques, response  (0) 2022.11.24
Servlet Mapping 하는방법 2가지  (0) 2022.11.23
JSP & Servlet - Servlet(기본) 2  (0) 2022.11.23

댓글