tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: getResourceAsStream() and exploring the archive
Date Mon, 01 Oct 2001 16:44:40 GMT

On Mon, 1 Oct 2001, chris brown wrote:

> Date: Mon, 1 Oct 2001 17:22:05 +0200
> From: chris brown <>
> Reply-To:
> To:
> Subject: getResourceAsStream() and exploring the archive
> The "ServletContext.getResourceAsStream()" method is quite useful when you
> know in advance the names of resources to load.  However, I'd like to know
> if there's any way to explore a WAR file (say, specify a "setup" subfolder
> in the WAR archive, then look at its contents).  This way, any number of
> files with any name can be read.  This is useful for example if each file is
> some sort of extensible setup info file, providing extensible deployment
> info.

In Servlet 2.3 (and therefore available in Tomcat 4.0), a new call was
added for precisely this purpose.  Check out the Javadocs for


Tomcat 4 uses this internally, for example, to build the directory
listings of available resources in a directory when there is no welcome
file available.

> Any suggestions, apart from decompressing the archive and using
> classes/methods in* ?

In a servlet 2.2 environment, this is pretty much your only choice, and
you have to make some non-portable assumptions about how tho figure out
where the directory or WAR file is.

> Thanks,
> Chris

Craig McClanahan

View raw message