分类: Java
2005-08-22 12:06:23
package market;
/**
* 侦听器程序测试
*/
public class marketListener implements javax.servlet.ServletContextListener {
private java.util.Timer timer;
public marketListener() {
System.out.println( "startup init" );
timer = new java.util.Timer( true );
}
public void contextDestroyed( javax.servlet.ServletContextEvent event ) {
System.out.println( "destory" );
timer.cancel();
}
public void contextInitialized( javax.servlet.ServletContextEvent event ) {
System.out.println( "start" );
System.out.println( event.getServletContext().getRealPath( "/" ) );
timer.schedule( new java.util.TimerTask() {
public void run() {
System.out.println( "TimerTask run..." );
}
} , 0 , 1000 );
}
}
对web.xml的配置