contextlistener.java

来自「利用JavaMail实现的发送及接收邮件的程序」· Java 代码 · 共 39 行

JAVA
39
字号
package com.digipower.automail.mailsender;import javax.servlet.*;import javax.servlet.http.*;import java.io.*;import java.util.*;import com.digipower.automail.AutoMailConstants;/** * <p>Title: </p> * <p>Description: TestStruts</p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: foxconn</p> * @author conti * @version 1.0 */public class ContextListener extends HttpServlet implements ServletContextListener {  //Notification that the web application is ready to process requests  private java.util.Timer timerSend = null;  private java.util.Timer timerReceive = null;  public void contextInitialized(ServletContextEvent event) {    AutoMailConstants.BOOTDIR = event.getServletContext().getRealPath("/") + "\\upload\\";//set the real path of uploadfileSystem.out.print("Context:" + AutoMailConstants.BOOTDIR);    timerSend = new java.util.Timer(true);    timerSend.schedule(new MyTask(event.getServletContext()), 0, AutoMailConstants.MAIL_SEND_INTERATE);    timerReceive = new java.util.Timer(true);    timerReceive.schedule(new ReceiveTask(event.getServletContext()), 0, AutoMailConstants.MAIL_SEND_INTERATE);  }  //Notification that the web application is ready to process requests  public void contextDestroyed(ServletContextEvent event) {    timerSend.cancel();    timerReceive.cancel();System.out.println("Timer Cancel");  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?