Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 21st, 2005, 07:20 AM
Registered User
 
Join Date: Oct 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.






Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript getElementById returns null VictorVictor ASP.NET 2.0 Professional 15 January 15th, 2010 06:53 PM
why File System GetAuditRules() returns null nomyjee ASP.NET 2.0 Professional 0 March 26th, 2006 08:06 PM
Access from a Dbase drop down returns NULL topshed Access 0 December 2nd, 2004 10:48 PM
Fedora and vmware cirudinezidane Linux 0 October 1st, 2004 07:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.