tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Uwe G√ľnther <...@cscc.de>
Subject Re: Finding out the absolute path to application (appBase)
Date Sat, 03 Oct 2009 11:10:19 GMT
Mark Thomas wrote:
> Caldarale, Charles R wrote:
>>> From: Igor Mukhin [mailto:iimuhin@mail.ru]
>>> Subject: Finding out the absolute path to application (appBase)
>>>
>>> what is the best way two find out the absolute path to directory 
>>> where the application is expanded (appBase)?
>> There's no guarantee that the application is expanded, or that components of it exist
anywhere in the file system.  (Or even that there is a file system.)
> 
> +1.
> 
>> What is your actual requirement?
> 
> If your requirement really is getting the appBase then try;
> 
> ((Host) standardContextInstance.getParent()).getAppBase()
> 

And maybe enhance the code from Mark with this part just in case appBase 
isn't absolute:

String appBaseName =
     ((Host) standardContextInstance.getParent()).getAppBase();

File appBase = new File(appBaseName);

if (!appBase.isAbsolute()) {
     appBase = new File(
         System.getProperty("catalina.base"),
         appBaseName);
}

-- 
Uwe

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


Mime
View raw message