tags:

views:

355

answers:

4

I have a directory on a linux box that I want to make publicly readable using Tomcat (5.5). I think this is easy to set up but can't find the appropriate documentation. Is there a simple way to accomplish this?

+2  A: 

It is possible by defining that directory as an web application, but it's not really what Tomcat is designed to do, other servers are far better at serving static content.

The way to define a directory as a webapp is to either

  • put it into $TOMCAT_HOME/webapps,
  • configure it in $TOMCAT_HOME/conf/server.xml or
  • provide a context .xml file and put it in $TOMCAT_HOME/conf/Catalina/localhost (by default, depends on your configuration).
Joachim Sauer
+1  A: 

You can just link it to a folder under webapps as a new "web application".

ln -s /path-to-real-folder /path-to-tomcat/webapps/publicfoldername

If I remember correctly, directory listing is enabled by default in tomcat, so the dir would be reachable. If not, this can be fixed in web.xml

Yoni Roit
+1  A: 

Although Tomcat is a good web server, it's not particularly made to list directories.

You might want to look at a web server like the Apache web server instead, it's more designed for this type of thing.

Stephane Grenier
A: 

If i deploy my webapp as a war file, how do i make sure that the link to the public folder exists everytime i deploy the war file? Is there a way to do this declaratively in tomcat config or web.xml?

Sathish
You didn't answer his question. Please create a new question when you ask one.As for your questions - include the folder within your war file and it will be created on deployment. You may have to include a 0 byte file if you have problems with a empty directory.
Stevko