Chris

>> BTW, why doesn't getRealPath return the full path to the
>> folder that the WAR file is in instead of null?
>
> You mean for a call like getRealPath("/")?

Yes, exactly!

> Well, that would require a path to be returned to the "root" of
> the application. Let's say that ROOT.war is in
> /home/tomcat/webapps/ROOT.war and also index.html is in the
> "root" of the WAR File.
>
> If you used getRealPath("/index.html") it would, as described,
> return null -- because there's no file path that could get you
> to that file.
>
> If you used getRealPath("/") and then added "/index.html" to
> the end of it, you'd expect to be able to read index.html from
> the resulting path (/home/tomcat/webapps/index.html). Not only
> does that not work (because the file isn't there), it's not
> even the right path. The "right" path (if there even is one)
> would be something like "/home/tomcat/webapps/ROOT.war/index.html".

While that is exactly the sort of result I would want, it does seem kind of 
hackish.  It isn't a response that can be supplied to a file system to retrieve 
the file.  It would require some sort of analysis and parsing.  So I can see 
why null is the safer answer, even if I don't like it.  ;-)

> So when the WAR is not unpacked, there really isn't any
> meaningful return value from getRealPath, even for special-
> cases like "" or "/".

Thanks for explaining.  I need to absorb all that info.

Also, maybe I'm not asking the right question.  How do you all configure the 
location of a special folder that is not part of the deployment package itself? 
 A site-specific config file perhaps?  Currently I'm using getRealPath for a 
relative-path location, but it sounds like that may need to be changed.  
Fortunately, the impact points are somewhat limited since all calls to 
getRealPath are wrapped with other centralized methods.

--
Cris Berneburg
CACI Lead Software Engineer

Reply via email to