package web;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
public class InitServlet extends HttpServlet {
/**
* 此Servlet仅用于在tomcat启动时初始化一些参数给其他Servlet使用
* 此类中只有init方法,不需要service
*/
@Override
public void init(ServletConfig config) throws ServletException {
// TODO Auto-generated method stub
super.init(config);
//向context存入流量,它是一个变量,默认值0
ServletContext ctx= getServletContext();
ctx.setAttribute("count", 0);
}
}