Yes, of course there is....
InputStream is = getServletContext().getResourceAsStream("/WEB-INF/myFile-dataResource.xml");
You can also get a list of files matching a particluar pattern using something like the following....
ServletContext context = getServletContext();
List list = new ArrayList();
Set paths = context.getResourcePaths("/WEB-INF/");
Iterator iter = paths.iterator();
while (iter.hasNext()) {
String currentPath = (String)iter.next();
if (currentPath.endsWith("-dataResource.xml")) {
InputStream is = context.getResourceAsStream(currentPath);
if (is != null) {
list.add(is);
}
}
}
Now you have a list of InputStream objects containing all your resources which exist inside WEB-INF. All you have to do is define a naming pattern and then just drop new ones in. They will get loaded without you ever having to modify the code to load the new documents.
Jake
At 02:46 PM 1/15/2003 -0500, you wrote:
I haven't always been able to keep up with this list, so my apologies if this question has been answered recently.The webapp which I am developing creates and modifies various data files, which should not be visible to an HTTP client. Currently I keep these data files within the WEB-INF directory of the webapp, and locate their filesystem path using getRealPath(). This has two obvious problems, though. The first is that the webapp can't be run from a WAR file. The second is that if the user installs a new version, it would be easy to accidentally overwrite the existing data files. I've thought of letting the admin set a Property giving the path of the directory where the data files should live; but if the webapp is in a WAR, the admin can't conveniently edit its .properties files. I want to keep things as simple as possible for the admin, which means not requiring a database or JNDI server to store path information. Surely there is a standard, kosher way of handling the location of data files, and I'm missing it. Can someone advise me on what it is? Gary McGath http://www.mcgath.com/ -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
