On 4/15/05, edward griebel <[EMAIL PROTECTED]> wrote:
> Were you intending to retrieve a file from within a WAR or just a
> random file on the web server box? The first case is much more
> interesting than just opening streams.

If the file in question is inside your webapp, the servlet API lets
you *read* it quite easily.  For example, lets say you are Struts :-),
and you want to read the web.xml file so you can figure out what
servlet mapping is being used (typically "/do/*" or "*.do") for
ActionServlet.

    ServletContext context = ... get reference to ServletContext
    InputStream stream = context.getResourceAsStream("/WEB-INF/web.xml");

The ServletContext reference is available from a bunch of places ...
from inside an Action, simply call:

    ServletContext context = getServlet().getServletContext();

> -ed

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to