Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File classpath

Status
Not open for further replies.

LuckyKoen

Programmer
Feb 14, 2005
57
BE
In my webapplication, there is a directory JavaSource for my java classes and a directory WebContent for my .jsp and .xml files. I want to open one of the xml files in my Action class .

Until now I used the full path (C:/ .../project/WebContent/myXMLFile.xml to open this file. Having this url hardcoded in my java class is not the way I would like to keep it, so I was wondering how I could open this file without having to give a full path. When I just use "myXMLFile.xml", the java class looks on the directory of my editor instead of the web application :(
 
Hi

Try some thing like this is action class

Code:
 String xmlFilePath = getServlet().getServletContext().getRealPath("/myXMLFile.xml");

Cheers
Venu
 
Many thanks, that's exactly what I was looking for.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top