当前jsp访问地址为:http://localhost:8080/app/test/contextPath.jsp
/app
String path = request.getContextPath();
http://localhost:8080/app/
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
/test/contextPath.jsp
String servletPath = request.getServletPath();
/app/test/contextPath.jsp
如果在js中,要加载本jsp页面同级的jsp文件,你就可能需要这个
String jspPath = path + servletPath.substring(0, servletPath.lastIndexOf("/"));
/app/test/contextPath.jsp
request.getRequestURI()
http://localhost:8080/app/test/contextPath.jsp
request.getRequestURL()