What is a WAR file
A WAR file stands for Web Application Archive and is a bundle for distributing or hosting a java web application. It is used as a bundle of files required by the web application that is written in Java programming language.
- Application code in the form of class files
- Servlets(which are also class files),
- Application’s deployment descriptor(web.xml),
- JAR files required by the application class files,
- Static files such as images and html files etc.
A war file needs to be deployed in a web server or an application server so that the application can be accessed over the browser.
This article will guide you how to deploy a WAR file in tomcat using different methods.
Deploy WAR in tomcat
There are following three ways to deploy a WAR file in tomcat. They are:
1. Placing WAR file in the deployment folder
Tomcat application server has a deployment directory where it places all the application WAR files. The location of this directory is
<Tomcat installation folder>/webapps.
Copy your application WAR file and place it in the above mentioned location. Restart tomcat and it will extract the WAR in the same folder and hence deploy the WAR.
Thus, after WAR is deployed, the deployment folder shall contain a WAR file and its extracted version.
Tomcat uses a variable
$CATALINA_BASE to refer to its root installation folder. Thus, webapps folder can also be referred as
This method is similar to the above method but in this method, you need to place the extracted version of the WAR in
Application will be deployed when tomcat is restarted.
3. Using tomcat manager
Tomcat provides a manager application which can be used to deploy a WAR. This application also provides a User Interface so that you can deploy the WAR interactively.
Launch tomcat console by opening the browser and navigating to URL at which tomcat is running.
Example, http://localhost:8080. This will open the below depicted page.
Choose the file and click Deploy button.
This approach has the advantage that you do not need to restart tomcat server. It will deploy the WAR automatically after upload.
Hit the clap below if you liked this post.