【Java开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了Java开源代码-BlogListener.java的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
package com.opensource.blog.web.servlet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.opensource.blog.comm.*;
public class BlogListener
extends HttpServlet implements ServletContextListener {
//Notification that the
web module is ready to process requests
public void contextInitialized(ServletContextEvent sce) {
String rootpath = sce.getServletContext().getRealPath("/");
//System.out.println(sce.getServletContext().getServletContextName());
if (rootpath != null) {
rootpath = rootpath.replaceAll("\\\\", "/");
}
else {
rootpath = "/";
}
Constant.ROOTPATH = rootpath;
}
//Notification that the servlet context is about to be shut down
public void contextDestroyed(ServletContextEvent sce) {
}
}