aspose file tools*
The moose likes JSP and the fly likes how to get the real path of a  file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how to get the real path of a  file" Watch "how to get the real path of a  file" New topic
Author

how to get the real path of a file

tianhan digeng
Greenhorn

Joined: Aug 22, 2010
Posts: 1
I set a virtual path in Tomcat server.xml ,such as <Context path="/demo" doBase="F:\webdemo"
in the F:\webdemo I build a folder "application" ,in the folder I have a file test.jsp ,now I just know the file name is test.jsp,so how to write in a jsp to get the real path of test.jsp
I am a chinese ,so the expression may not right ,please forgive......
Ram Narayan.M
Ranch Hand

Joined: Jul 11, 2010
Posts: 247

It can be got in the form of pathOfJsp=request.getContextPath()+"/application/test.jsp"


SCJP 6 [SCJP - Old is Gold]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61589
    
  67

Ram Narayan.M wrote:It can be got in the form of pathOfJsp=request.getContextPath()+"/application/test.jsp"

The context path is used to form the URL of the resource, and has nothing to do with the file path.

To find the file path of a resource, use the ServletContext.getRealPath() method().


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get the real path of a file