Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Within a web application I want to create a "virtual directory" that lives under the WEB-INF directory. In effect what I am trying to accomplish is the same effect as creating a soft link in the filesystem if the application were run exploded. I am trying to accomplish this in both (most importantly) weblogic, as well as (in an ideal world) jetty.

I am aware of the virtual directory configurations, however these do not suit my purposes as I do not want the content served directly via a URL (hence why it lives in WEB-INF). I have found nothing in the configuration document for jetty or weblogic that seems to provide a similar concept for resource resolution (I did try adding "extraClassPath" to jetty, but that was not successful). As further background the applications is using spring MVC and the view resolvers are pointing to JSPs under WEB-INF

<bean id="myResolverBean"
    p:prefix="/WEB-INF/foo/baz/" p:suffix=".jsp" />

After looking through the spring code I am under the belief, that it is doing nothing in regards to the resource loading, it is the container (weblogic / jetty) that resolves the paths. I have also tried using file URIs but it seems the container will always interpret the path as relative to the context root (i.e. there are no absolute paths).

So my question is, is it possible to add any kind of configuration directive to the web.xml, server configurations, or spring configuration to accomplish this?

share|improve this question
up vote 1 down vote accepted

Not surprisingly the answer to this question in weblogic is the virtual directory. The directive provides both (what I consider to be) the standard behavior of mapping a URL to some set of (usually static files) to be served, but also acts as a "virtual soft link" when the path is under WEB-INF and still provides the desired behavior of giving a 404 if you make a request via to the browser for such a URL (I think I misconfigured something the first time I tried this). So the following will produce the desired behavior:


I have also discovered a similar functionality in Jetty. It is accomplished by specifying multiple "base resources" in the configuration. There is some jetty documentation that provides an explanation and some examples. One feature (I can see this being both helpful and harmful depending on the situation) is that the structures are merged so you can have paths that collide and they will be resolved in order of specification. The above example for jetty:

<Set name="baseResource">
  <New class="org.mortbay.resource.ResourceCollection">
      <Array type="java.lang.String">

One catch for both of these is the directory structure must be recreated in the external directories (i.e. it must be /absolute/path/outside/of/webapp/WEB-INF/foo) to work correctly, as far as I can tell there is no way to map one directory to another arbitrarily named directory.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.