问题
in servlet, as we can access the real path of deployed project
ServletContext context = getServletConfig().getServletContext();
string contextStr = context.getRealPath(".....");
How can i access the deployed project path in JSP page, any idea please ?
回答1:
<%=request.getRealPath("write_your_file_name")%>
回答2:
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.
回答3:
note, as of version 2.1 you should use
request.getServletContext().getRealPath("your_file_name")
来源:https://stackoverflow.com/questions/6646679/in-jsp-get-realpath-of-deployed-project