package com.servlet.demo3;
import java.io.IOException;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class ServletDemo2 implements Servlet{
//Servlet对象被实例化的时候init方法就会执行,而且只执行一次
@Override
public void init(ServletConfig config) throws ServletException {
// TODO Auto-generated method stub
System.out.println("servlet初始化了...");
}
//任何一次请求都会执行service方法,可以执行多次
@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println("servlet执行了...");
}
//servlet从服务器中移除或者服务器关闭的时候,会销毁servlet,销毁时执行,只执行一次
@Override
public void destroy() {
// TODO Auto-generated method stub
System.out.println("servlet销毁了...");
}
@Override
public ServletConfig getServletConfig() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getServletInfo() {
// TODO Auto-gene
rated method stub
return null;
}
}