⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contextlistener.java

📁 利用JavaMail实现的发送及接收邮件的程序
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -