How to remove the application name in Tomcat URL

In order to access a web application deployed on Tomcat, it is required by default to write the application name in the URL.

However, getting rid of the application name in a production environment is a must, to do so, you should deploy your application as a root web application.

In this tutorial, we show 2 ways of deploying root web applications on Tomcat.

1. Root WAR

Instead of naming the application WAR file as the application name, you can name it as ROOT.war and simply deploy it under {TOMCAT_HOME}/webapps.

Tomcat would then treat the application as a root application, hence redirects to it on every root access.

P.S: just make sure to remove the default ROOT folder provided by Tomcat before you deploy your own ROOT.war.

2. Root Context

Another way of deploying a root web application is to define ROOT.xml under {TOMCAT_HOME}/conf/Catalina/localhost. The XML normally points to the application name using the docBase attribute as below:

Through the above ways, you can access the web application as {TOMCAT_HOST_IP}:{TOMCAT_PORT}.

 

Hussein Terek

Founder of programmergate.com, I have a passion in software engineering and everything related to java environment.

You may also like...

Leave a Reply

avatar