获得Jsp相对路径的办法
比如http://www.jdon.com:81/jive/temp/index.jsp中
如果要获得/jive/temp/这个路径,通过正常途径是比较难的。
Servlet API没有提供直接获得这种路径的办法,现在有一个解决办法如下:
//获得/jive/temp/index.jsp
String pathname = request.getRequestURI();
//去处index.jsp
File tempfile = new File(pathname).getParentFile();
//获得/jive/temp/
String realbase =pathname.substring(0,tempfile.toString().length()+1);
out.println("<br>"+"==="+realbase);
其他人有更好的主意吗?