Brain Dump

A place to store my random thoughts and anything else I might find useful.

Archive for November, 2008

Redirecting tomcat ROOT

Posted by mzanfardino on November 7, 2008

The goal is to force tomcat to redirect the default root homepage to another page altogether. With Apache2 it’s a simple matter of adding some code to apache2.conf

Redirect /index.html http://$server/$path/index.html

Where $server and $path represent the server and path to redirect.

This does not appear to be the case with Tomcat, or if it is, I can’t seem to find the right file to update in order to make this change. However, I did find a really good tip from another on how to override the default home page (source sited below).

Essentially when Tomcat is installed it’s configured to look for index.html, index.htm, and index.jsp in $TOMCAT_HOME/webapps/ROOT. (which for my system is /usr/local/tomcat/webapps/ROOT). The index.jsp file located there is the administrator welcome page that is displayed by default. Simply creating an index.html page will override the jsp as the html is loaded before the jsp according to the configuration file located in $TOMCAT_HOME/conf/web.xml. The files and their order is defined in <welcome-file-list>.

The index.html needs to be quite simple and should look as follows:

    <meta http-equiv="refresh" content="0;URL=http[s]://$server/$path/index.html">

This to me does not appear to be the ideal solution, as it forces the server to perform another round trip, which is inefficient particularly if you are redirecting to the same server but to a different application. However, until I can find a more proper solution such as the apache2 solution, this will have to be what I use.

Source: Tomcat Wiki


Posted in tomcat, webserrvices | Tagged: , , | 3 Comments »