Making a java web application as the root of a domain name in Tomcat 6

jakarta-ee, java, tomcat

Solution

This can be done in Tomcat in basically two ways:

Set `path` attribute of `<Context>` element in `Webapp/META-INF/context.xml` (or `Tomcat/conf/server.xml`, depending where you'd like to define it) to an empty String. E.g.

<Context path="">

Rename it to `ROOT.war` and Tomcat will automagically deploy it as ROOT.

Outside Tomcat there are more ways to do this, such as (virtual) proxy, URL rewriting with `.htaccess`, etcetera.

Problem

I'm currently developing a Java web application myapp and when deployed in Tomcat 6 server, I access myapp with this URL: `http://localhost:8080/myapp` Instead I want to access my application using this URL: `http://myapp:8080` since myapp will be the only application deployed in my Tomcat 6. How do I do it?

Original source