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

I have a Java web app deployed on Tomcat 6 on Ubuntu 9.04. For certain images, I want to create a symbolic link to another directory of images. This will allow me to reference images that remain on the server even if the application is removed and redeployed.

The application is deployed in the /var/lib/tomcat6/webapps/ROOT/ directory and the images directory exists in the war. When I deploy the application, I create a symbolic link to the saved_images directory so there is a path like /var/lib/tomcat6/webapps/ROOT/images/saved_images/.

In the application, I have the following code:

File file = new File("/var/lib/tomcat6/webapps/ROOT/images/saved_images/abc.jpg");
boolean fileExists = file.exists();

The fileExists value is true when the code runs, but the images aren't displayed on the page when referenced like images/saved_images/abc.jpg.

The permissions of the images in the /var/lib/tomcat6/webapps/ROOT/images and /var/lib/tomcat6/webapps/ROOT/images/saved_images are the same (the owner and group is tomcat6, which is the same as the other files deployed in the war). If I remove the sym link and put the saved_images files in a directory of the same name, the images are displayed. How can I have the page display these images when the directory is a sym link without having to copy the files to a real directory?

share|improve this question
up vote 2 down vote accepted

Have you tried adding the following to your context.xml file?

<Context path="/foobar" allowLinking="true">
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.