有關getRealPath()相關問題

翻一下 api doc http://java.sun.com/j2ee/1.4/docs/api/index.html
你會發現到 request.getRealPath( ) 這個方法己經 Deprecated
現在都會使用 ServletContext.getRealPath(java.lang.String)
如果你是要寫在 JSP 時,application.getRealPath(java.lang.String)

另外如果你的 test2.jsp 是放在 {webapp}\ROOT\project\News\test2.jsp
的確只能找到 {webapp}\ROOT 的路徑
所以還要搭配
1 request.getRequestURI()
2 request.getRequestURL()
3 request.getServletPath()

才能完整做出你的需求

PS. 反正都能解決 .. 所以不需求再做一個 method 來直接取得 所在local端的絕對位置

你可能感兴趣的:(java,html,jsp,sun)