on 9/1/01 9:48 PM, Craig R. McClanahan at [EMAIL PROTECTED] wrote:

>> Is there a Servlet spec-compliant way to get the webapp's directory's path
>> programmatically, from within a servlet?
> 
> No.
> 
>> Something like calling
>> ServletConfig.getInitParameter("docBase"), but something that's standard,
>> and that does not require me to specify the path explicitly in a
>> configuration file?
>> 
> 
> You are starting from an incorect assumption, that there *is* such a thing
> as a portable "directory path" to a web application.  It is entirely legal
> for a servlet container to run a web application directly from a WAR file
> (in which case there is no expanded directory), or by storing its static
> resources in some other sort of structure (such as being BLOB objects in a
> database).

Okay. I get that. How does one access a resource, then, whether it's a file
in a directory or a file in a WAR file? For example, we have properties
files that specify certain things for our web app. Currently, I provide a
full path, from root, to this file as an init param to a servlet that gets
loaded at context startup.

I'd like to be able to refer to this file relative to the web app's
directory (or within the web app's) .WAR file. Can you tell me how I'd go
about doing this, or what concepts to search for in the documentation to
answer this question?

As always, thanks for your help,

------------------------------------------------------------
Roderick Mann               rmann @ latencyzero.com.sansspam


Reply via email to