getContextPath() :/JSTLDemo
getRequestURI() :/JSTLDemo/index.jsp
getRequestURL() :http://localhost:8080/JSTLDemo/index.jsp
getServletPath() :/index.jsp
getQueryString() :name=123&dmeo=456
getRequestURI() :/JSTLDemo/index.jsp
getRequestURL() :http://localhost:8080/JSTLDemo/index.jsp
getServletPath() :/index.jsp
getQueryString() :name=123&dmeo=456
<%
out.println("getContextPath() :" + request.getContextPath() + "<br/>");
out.println("getRequestURI() :" + request.getRequestURI() + "<br/>");
out.println("getRequestURL() :" + request.getRequestURL() + "<br/>");
out.println("getServletPath() :" + request.getServletPath() + "<br/>");
out.println("
getQueryString() :" + request.getQueryString());
request.getScheme() + "://" + request.getServerName() + ":" +
request.getServerPort()
%>
String s = request.getRequestURL().toString();
String m = request.getRequestURI();
int i = s.lastIndexOf(m);
String url = s.substring(0, i);
java.io.File file = new java.io.File(url, "D:/");
String path = file.getPath();
response.getWriter().write(path);
获取服务器下根目录