Image of How to deploy web applications on Tomcat

ADVERTISEMENT

Table of Contents

Introduction

In this tutorial, we describe 2 ways for deploying Java web applications on Tomcat application server.

1. War file

The typical way for deploying a Java web application on Tomcat is to archive the application in a WAR file and deploy the file directly under /webapps.

In order to access the application, simply append the name of the war file to the URL of Tomcat.

2. Context file

Another way of deploying the Java web application on Tomcat is to define a context XML file under /conf/Catalina/localhost with the following format:

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

where docBase attribute points to the location of the web application, and the name of XML defines the application name.

In order to access the application, simply append the name of the context XML file to the URL of Tomcat.

Summary

In this tutorial, we describe 2 ways for deploying Java web applications on Tomcat application server.

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.

Final Notes