On Wed, 14 Mar 2001, Richard Gill wrote:

> Hi, I need a way to find out at run time the base directory for a context.
>
> ie: which directory the web app is installed in. This is because I need to
> determine the path to the WEB-INF directory so I can create properties files
> there automatically as required.
>
> I can't find anything in the API. Anyone have any ideas?

Not sure you looked hard enough :-).  Depending on exactly what you
want, some or all of the following may be helpful:

getContextPath() (in ServletRequest)
getRealPath() (in ServletContext)
getPathTranslated() (in ServletContext)
getResource() (in ServletContext)
getResourceAsStream() (in ServletContext)

Sounds like the latter two may be most relevant, you may not even need
to know the context to use them.  And they do support writing in
certain situations.  (Sorry, don't really know the details.)

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to