tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: Reading Files?
Date Fri, 05 Oct 2001 19:18:26 GMT


On Fri, 5 Oct 2001, Hunter Hillegas wrote:

> Date: Fri, 05 Oct 2001 12:10:54 -0700
> From: Hunter Hillegas <lists@lastonepicked.com>
> Reply-To: tomcat-user@jakarta.apache.org
> To: Tomcat User List <tomcat-user@jakarta.apache.org>
> 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



Mime
View raw message