request.getContextPath() 获取项目名称,如 /BiYeSheJi
getServletContext().getRealPath("/") 获取项目根目录,如 C:\install files\programing software\eclipse\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\BiYeSheJi\
原文:http://www.cnblogs.com/z-sm/p/3948282.html