One option is to use a servlet that serves static files from directories and map that servlet in your web application's web.xml. This is nowhere near as robust or secure as putting httpd infront of your servlet containers. Again since this _could_ point outside the application directory it's a poor solution.
This approach is what we've done to use shared resources (static content) amongst multiple apps. In some deployment environments, running Apache in front of Tomcat is a no-go for our customers, so implementing this way allows us to *optionally* use Apache:
If Apache present, image is at http://www.site.com/images/a.gif
and physically at /.../images/a.gif
If Apache is not present, image is at http://www.site.com/webAppA/static?a.gif
and physically at /.../images/a.gif
Point being, implementing the serving as a separate servlet can give you additional flexibility at deployment time. The assertion that this diminishes robustness and/or security must be taken in context -- in many situations, this can be preferable to running with Apache in front. As always, YMMV.
justin
Otherwise (as in Carl's suggestion): You can "overlap" URI mappings to contexts.
So you can map:
/app1 -> fooApplication.war /app1/images -> /usr/home/tomcat/images
as long as your images directory is a deployable web application.
----Original Message Follows---- From: "Mike Curwen" <[EMAIL PROTECTED]> Reply-To: "Tomcat Users List" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Subject: Is there such a beast ? (virtual directories) Date: Tue, 13 Jul 2004 10:12:56 -0500
Hello all,
I had a friend ask me on the phone a couple days ago, and now a question has popped up at javaranch. I've looked in the docs and googled, but haven't found a definitive 'no' answer (shouldn't life be that simple?). Thought I'd ask here.
Is there such a thing as directory aliasing / virtual directories (like you get in Apache), available in Tomcat?
so you'd specify that /images is *really* over here at /usr/local/some/funky/place/images
I like to tell people they don't need Apache, unless they're doing "special" stuff. Would this be one of those "special" things ?
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
