开发者

in jsp, get realPath of deployed project

开发者 https://www.devze.com 2023-03-19 02:26 出处:网络
in servlet, as we can access the real path of deployed project ServletContext context = getServletConfig().getServletConte开发者_如何学Cxt();

in servlet, as we can access the real path of deployed project

ServletContext context = getServletConfig().getServletConte开发者_如何学Cxt();
string contextStr = context.getRealPath(".....");

How can i access the deployed project path in JSP page, any idea please ?


<%=request.getRealPath("write_your_file_name")%>


It should work just the same, for example by accessing ${pageContext.servletContext.getRealPath("...")} to get the same results. JSP are nothing more than servlets after they got compiled.


note, as of version 2.1 you should use

request.getServletContext().getRealPath("your_file_name")
0

精彩评论

暂无评论...
验证码 换一张
取 消