getRealPath returns null in Fedora
Hi,
I need to access my drictory(s) in my tomcat application from servlets to list the files available in the drictory. Also, I need to upload files, for which I need to get the path too, but the method getServletContext().getRealPath("SomeDirectory") returns null. My application works perfectly fine under winodws, however, under fedora it returns null and it is installed as war file using tomcat. I can access other files in the same direcoty of war file. Please help me out. Here are some codes which I tested and the string path is always coming as null, althought getServletConfig() or getServletContext() are not null.
String path = getServletConfig().getServletContext().getRealPath ("UploadedFiles/forms");
OR
String path = getServletContext().getRealPath("UploadedFiles/forms");
OR
String path = getServletConfig().getServletContext().getRealPath ("UploadedFiles/forms");
OR
String path = getServletConfig().getServletContext().getRealPath (java.io.File.separator+"UploadedFiles"+java.io.Fi le.separator+"forms"+java.io.File.separator);
After getting path value I would like to do:
File file = new File(path);
String[] myFiles = file.list();
...
Any help will be appreciated.
Thanks.
|