Cory
Cory

Reputation: 24240

Use Tomcat to serve a directory?

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?

Upvotes: 4

Views: 5244

Answers (3)

Stephane Grenier
Stephane Grenier

Reputation: 15927

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.

Upvotes: -1

Yoni Roit
Yoni Roit

Reputation: 28686

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

Upvotes: 2

Joachim Sauer
Joachim Sauer

Reputation: 308001

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

Upvotes: 4

Related Questions