servlet路径

1 servlet路径

 

String webRealPath=request.getSession().getServletContext().getRealPath("/");

返回: C:/bea/user_projects/domains/base_domain/autodeploy/工程名/

 

这里用“/”,返回的时web应用根目录的物理路径

 

request.getContextPath()输出: /工程名

获得URI

request.getRequestURI()输出:  /工程名/index.jsp

获得URL

request.getRequestURL()输出:

http://localhost:7001/工程名/index.jsp

 

 

 

 

你可能感兴趣的:(servlet路径)