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?
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).
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
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.
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?