Listener、Filter、Servlet与Java Web项目初始化的工作(2)
TimerTest.initTimer(seconds);
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
System.out.println("+++++ doFilter() +++++");
}
public void destroy() {
this.seconds = null;
}
public Long getSeconds() {
return seconds;
}
}
[java]
package com.tom.servlet;
import java.io.IOException;
import java.util.Timer;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class HelloServlet extends HttpServlet {
private static final long serialVersionUID = -7693562670980406523L;
public HelloServlet() {
System.out.println("----- Servlet() -----");
}
public void init() throws ServletException {
System.out.println("----- ServletInit() -----");
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTest01(), 0, 6000L);
}
public void destroy() {
System.out.println("----- ServletDestroy() -----");
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
}
[java]
package com.tom.servlet;
相关新闻>>
- 发表评论
-
- 最新评论 更多>>