tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: Rewriting via web.xml instead of mod_rewrite?
Date Thu, 11 May 2000 16:54:53 GMT
Volker Stolz wrote:

> We're using Tomcat-standalone, i.e. without using Apache or another server.
> I want to redirect every access to the URL /path/to/files to
> /servlet/class/path/to/file. Is this possible? If yes, is there a way of
> mapping an entire directory (/path/to) instead of each file?

If the servlet you want to forward to is fixed, here's one approach.  Add the
following entries into your web.xml file:



Your servlet will be called for every request URI that starts "/path/to" (after
the context path, if any).  It can pick up the "files" part of the request URI
by calling request.getPathInfo().  One thing you might want to do is read the
actual file that this refers to.  For that, you can do something like:

    String pathInfo = request.getPathInfo();
    InputStream stream =

and read from this input stream.

> Volker

Craig McClanahan

View raw message