in jsp, get realPath of deployed project
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")
精彩评论