본문 바로가기
web/JSP

서블릿 동작 과정

by 바까 2020. 7. 15.
반응형
Firtst.java
package exam01;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class First extends HttpServlet {
	
	//
	@Override
	public void init() throws ServletException {
		// TODO Auto-generated method stub
		System.out.println("init() 메서드 호출");
	}
	//브라우저의 요청을 처리한다.
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		System.out.println("doGet() 메서드 호출");
	}
	//
	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		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">
  
  <servlet>
  	<servlet-name>firstExam01</servlet-name>
  	<servlet-class>exam01.First</servlet-class>
  </servlet>
  
  <servlet>
  	<servlet-name>secondExam01</servlet-name>
  	<servlet-class>exam01.Second</servlet-class>
  </servlet>
  
  <servlet-mapping>
  	<servlet-name>firstExam01</servlet-name>
  	<url-pattern>/test01</url-pattern>
  </servlet-mapping>
  
  <servlet-mapping>
  	<servlet-name>secondExam01</servlet-name>
  	<url-pattern>/test02</url-pattern>
  </servlet-mapping>
  
</web-app>

 

동작과정


 

반응형

댓글