getServletContext()
request.getRealPath(java.lang.String
Deprecated. As of Version 2.1 of the Java Servlet API, use ServletContext.getRealPath(java.lang.String) instead.
在JSP中可以这样用
request.getSession().getServletContext().getRealPath("/") 得到站点的绝对地址
在servlet或者struts中还可以这样用
this.getServletContext().getRealPath("/");
request.getContextPath()得到的是项目的名字,如果项目为根目录,则得到一个"",即空串,
如果项目名为Test, <%=request.getContextPath()% >/ 将得到Test/。
request.getScheme();
返回的协议名称,默认是http
request.getServerName()
返回的是你浏览器中显示的主机名
getServerPort()
获取服务器端口号