in jsp, get realPath of deployed project

我与影子孤独终老i 提交于 2020-01-17 02:41:32

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!