Use Tomcat to serve a directory?

I have a directory in a Linux box that I want to make public with Tomcat (5.5). I think this is easy to set up, but cannot find the relevant documentation. Is there an easy way to do this?

+4
source share
3 answers

Although Tomcat is a good web server, it is not particularly suitable for listing directories.

Instead, you can look at the web server, for example, the Apache web server, which is more designed for this type of thing.

0
source

You can define this directory as a web application, but not exactly what Tomcat is for; other servers serve static content much better.

A way to define a directory as webapp is either

  • enter $TOMCAT_HOME/webapps ,
  • configure it in $TOMCAT_HOME/conf/server.xml or
  • provide the context file .xml and put it in $TOMCAT_HOME/conf/Catalina/localhost (the default depends on your configuration).
+4
source

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

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

If I remember correctly, the directory list is included by default in tomcat, so the directory will be available. If not, this can be fixed in web.xml

+2
source

All Articles