Image of How to remove the application name in Tomcat URL

ADVERTISEMENT

Introduction

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 /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 /conf/Catalina/localhost. The XML normally points to the application name using the docBase attribute as below:

<?xml version="1.0" encoding="utf-8"?>
<Context reloadable="false" docBase="E:\Workspace\Test-Web" useHttpOnly="false"/>

Through the above ways, you can access the web application as :.

Summary

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

Next Steps

If you're interested in learning more about the basics of Java, coding, and software development, check out our Coding Essentials Guidebook for Developers, where we cover the essential languages, concepts, and tools that you'll need to become a professional developer.

Thanks and happy coding! We hope you enjoyed this article. If you have any questions or comments, feel free to reach out to jacob@initialcommit.io.