1 package org.nemesis.forum.config; 2 3 import java.io.File ; 4 5 import javax.servlet.ServletContext ; 6 import javax.servlet.http.HttpServlet ; 7 import javax.servlet.http.HttpServletRequest ; 8 import javax.servlet.http.HttpServletResponse ; 9 10 import org.apache.commons.logging.Log; 11 import org.apache.commons.logging.LogFactory; 12 13 public class InitServlet extends HttpServlet { 14 15 private static Log log=LogFactory.getLog(InitServlet.class); 16 17 public static String DATA_PATH; 18 19 20 25 public void init() { 26 log.info("--------INIT START-------------"); 27 28 29 if(getServletConfig().getInitParameter("dataPath") !=null) { 30 DATA_PATH = getServletConfig().getInitParameter("dataPath"); 31 }else{ String realPath=getServletContext().getRealPath(""); 33 if(realPath==null){ 34 System.err.println("your system doesn't support getServletContext().getRealPath() method, set absolute path in your web.xml"); 35 log.fatal("your system doesn't support getServletContext().getRealPath() method, set absolute path in your web.xml"); 36 System.exit(1); 37 } 38 DATA_PATH= realPath+File.separator+"WEB-INF"+File.separator+"nemesis-data"; 39 } 40 41 42 43 ServletContext context = this.getServletConfig().getServletContext(); 45 46 String jcp = System.getProperty("java.class.path"); 47 48 log.info("System classpath :\n"+System.getProperty("java.class.path")); 57 58 60 String encoding = System.getProperty("file.encoding"); 61 63 log.info("System file.encoding :"+encoding); 64 66 String tempdir = System.getProperty("java.io.tmpdir"); 68 69 log.info("System TEMP DIR :"+tempdir); 70 72 log.info("--------INIT END-------------"); 102 103 104 } 105 106 107 108 public void doService(HttpServletRequest req, HttpServletResponse res) { 109 return; 110 } 111 112 115 public void destroy() { 116 super.destroy(); 117 118 119 } 120 121 } 122 | Popular Tags |