<%
String path1 = application.getRealPath(request.getRequestURI()); //当前请求的JSP文件的物理路径
String path2 = application.getRealPath("/"); //当前WEB应用的物理路径
String path3 = request.getRequestURI();
StringBuffer path4 = request.getRequestURL(); //getRequestURL()返回的是StringBuffer
String virtualPath = request.getServletPath(); //虚拟路径
String realPath = request.getRealPath(virtualPath);//物理路径
%>
request.getRequestURI()与request.getRequestURL()的区别
request.getRequestURI()只是显示的是文件的名称 // /cta/xiahu/xiahu_add.jsp
request.getRequestURL()显示的全部的URL // http://localhost:7001/cta/xiahu/xiahu_add.jsp
request.getRequestURL()显示的全部的URL // http://localhost:7001/cta/xiahu/xiahu_add.jsp
原文:http://blog.csdn.net/itmyhome1990/article/details/14524127