On Fri, 5 Oct 2001, Hunter Hillegas wrote:

> Date: Fri, 05 Oct 2001 12:10:54 -0700
> From: Hunter Hillegas <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: Tomcat User List <[EMAIL PROTECTED]>
> Subject: Reading Files?
>
> I want to read my XML config file from inside my Web app...
>
> I put the file inside WEB-INF. Is there a way to get the file system path to
> that location from the container so I can pass that to the File object to
> locate the file?

You shouldn't use File I/O, because you might be running in a container
that doesn't expand WAR files, or uses some other technique to store the
static resources.

  InputStream stream =
    getServletContext().getResourceAsStream("/WEB-INF/myconfig.xml");

>
> Thanks,
> Hunter
>
>

Craig


Reply via email to