You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by DEEPA M N <de...@yahoo.co.in> on 2006/02/01 06:20:08 UTC

Re: Download file Problem - 404 error

Hi,
  wen i checked the log file, i think the error might be in the line of the code.
  root = propFile.getProperty("app.directory");
   
  This code should be able to download the files from the server. so i m using application.properties where
  app.directory="D:\\temp\\files\\"
   
  I doubt because of this line am i not able to run the appln. Pls let me know where should i place this application.properties file.
   
  Regards
  deepa
   
  Here is a code snnipet:
  String JAVA_HOME = "application.properties";
 // Get a handle on the properties file
 try{
 in = new FileInputStream(JAVA_HOME);
 propFile = new Properties();
 propFile.load(in);
 }
 catch (IOException ignore){}
 separator = "/";
 // Get the directory from the application.properties file
 // e.g. C:\\Temp\\Files\\
 root = propFile.getProperty("app.directory");
   
  Deepa
  
 }



				
---------------------------------
 Jiyo cricket on Yahoo! India cricket

Re: Download file Problem - 404 error

Posted by Glen Mazza <gr...@verizon.net>.
DEEPA M N wrote:

> Hi,
>   wen i checked the log file, i think the error might be in the line of the code.
>   root = propFile.getProperty("app.directory");
>    
>   This code should be able to download the files from the server. so i m using application.properties where
>   app.directory="D:\\temp\\files\\"
>    
>   I doubt because of this line am i not able to run the appln. Pls let me know where should i place this application.properties file.
>    

I believe it should go in the WEB-INF/classes directory.  (not a 
subdirectory of that, I am unsure if that would also work.)

But I would comment out this portion of the code that opens and reads 
from the properties file and just hardcode the directory for now, while 
you are trying to get your servlet to activate.  (Better yet, even 
comment out the portion that uses this directory information, while you 
are trying to get the servlet to activate.  Best to proceed sequentially 
here rather than try to solve multiple problems at once.)

Glen

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Download file Problem - 404 error

Posted by David Smith <dn...@cornell.edu>.
I've done code similar to this. Yore can go one of two ways:

1) Store your properties file in WEB- INF/classes and then call 
propFile.load(this.getClass().getClassLoader().getResourceAsStream("application.properties''));

2) Store the properties file anywhere in the webapp and call
propFile.load 
(request.getSession().getServletContext().getResourceAsStream( "/[webapp 
rel path]/application.properties"));

I think No. 1 would be preferable as it doesn't require a request object 
and can exist anywhere in code.

-- David

DEEPA M N wrote:
> Hi,
>   wen i checked the log file, i think the error might be in the line of the code.
>   root = propFile.getProperty("app.directory");
>    
>   This code should be able to download the files from the server. so i m using application.properties where
>   app.directory="D:\\temp\\files\\"
>    
>   I doubt because of this line am i not able to run the appln. Pls let me know where should i place this application.properties file.
>    
>   Regards
>   deepa
>    
>   Here is a code snnipet:
>   String JAVA_HOME = "application.properties";
>  // Get a handle on the properties file
>  try{
>  in = new FileInputStream(JAVA_HOME);
>  propFile = new Properties();
>  propFile.load(in);
>  }
>  catch (IOException ignore){}
>  separator = "/";
>  // Get the directory from the application.properties file
>  // e.g. C:\\Temp\\Files\\
>  root = propFile.getProperty("app.directory");
>    
>   Deepa
>   
>  }
>
>
>
> 				
> ---------------------------------
>  Jiyo cricket on Yahoo! India cricket
>   



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org