Tomcat relative directory paths
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Steve_Higgins
Posted On:   Monday, September 29, 2003 08:50 AM

Hi All, I'm using Tomcat 3.3.1 in a Win2000 environment (for reasons I won't go into right now) and would like to know if I can change something that has been bugging me for a while. My application creates various work files as it runs and I'd like to be able to control where they are created. I have an entry in web.xml like this: xmlDirectory xml/ Temp xml directory which I read using getServletContext() . The application then creates its files in that directory. I originally used absolute pathnames for the param value but would prefer the directory to be relative to the context home directory of my application. Coded as it is above it creates file in TOMCAT_   More>>

Hi All,

I'm using Tomcat 3.3.1 in a Win2000 environment (for reasons I won't go into right now) and would like to know if I can change something that has been bugging me for a while.

My application creates various work files as it runs and I'd like to be able to control where they are created. I have an entry in web.xml like this:

			

xmlDirectory
xml/
Temp xml directory


which I read using getServletContext() . The application then creates its files in that directory. I originally used absolute pathnames for the param value but would prefer the directory to be relative to the context home directory of my application. Coded as it is above it creates file in TOMCAT_HOME/bin/xml which is worse than using absolute pathnames as far as I'm concerned.

Is there a way to retrieve the full pathname of the context home? Or does anyone have any suggestions?

Many thanks

Steve

   <<Less

Re: Tomcat relative directory paths

Posted By:   Steve_Daskam  
Posted On:   Thursday, October 9, 2003 07:38 AM

In your parm you need to put a "/" before your path (i.e. /xml). This makes the path relative to your application directory. You then can use the following to get the REAL path:



String path = application.getRealPath(pathParm);


Hope this helps.

Steve Daskam

About | Sitemap | Contact