Accessing files using relative/absolute path
I am running my servlet using tomcat on my computer (instead of on the web). It involves accessing a password file. Here's how I put my files:
To access the pwd.txt file, I try to get the absolute path to the file as follows:
String root = getServletConfig().getServletContext().getRealPath("/");
String adminFile = root + "Password/pwd.txt";
With tomcat, I am expecting to get
as the location for the file.
Instead, I am getting the location of the file in the file system, that is:
D://Program Files/Apache Software Foundation/Tomcat 6.0/webapps/myproj/Password/pwd.txt
Yes, as it stands, my servlet can still find the file. But I'm not sure if this is a problem or not. I mean when it comes the time for me to deploy the servlet for real, can it still find the file?