import java.util.Timer;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class SmsListener implements ServletContextListener{
private Timer timer=null;
public void contextDestroyed(ServletContextEvent sce) {
timer.cancel();
}
public void contextInitialized(ServletContextEvent sce) {
timer=new Timer(true);
//Set task schedule, start and interval time
timer.schedule(new NoteReplyTask(), 0, 86400000);
}
}
public class MyTask extends TimerTask {
public void run() {
// System.out.println("call at " + (new Date()));
// TODO add specific task code here
}
}
webXml configuration