Deploy And Undeploy Java EE Web Applications In Tomcat

Deploy or undeploy java web applications in Tomcat are very easy to handle. You can either deploy or undeploy your war file manually or use tomcat manager. This article will show you how to do that.

1. Manually Deploy or Undeploy.

1.1 Manually Deploy.

  1. To manually deploy a .war file is so easy, you just need to copy that .war file to your tomcat webapps folder.
  2. After that, the war file will be extracted to a subfolder under the webapps folder automatically.
  3. Then you can access your web application by browsing the URL like http://localhost:8080/web-app-name/ ( for example http://localhost:8080/Dev2qaWebAppExample/). The web-app-name is usually the same as the .war file name.
  4. If you see a web page with the success message ( for example You are welcome to the demo Java EE web application for ) that means your web application has been deployed successfully.
  5. If you encounter any errors, you can check the content in the war file extracted folder. The content in it should like below.
    ├── WebContent
    │   ├── META-INF
    │   │   └── MANIFEST.MF
    │   ├── WEB-INF
    │   │   └── web.xml
    │   ├── index.html
  6. The web.xml content should be:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="" xmlns="" xsi:schemaLocation="" version="3.1">  
    <!-- This is the java EE web application display name. -->
      <!-- This is the welcome file list. They are the files to be shown when you 
           do not add file name after java EE web application name.
           For example if you browse following url.
           Then Tomcat server will find below page first.
           If not found then find
           If not found then find
           Until it find one, then show that page content to client.
           If no file found, then return a 404 http status code to client.
  7. You can see the comments in the above web.xml to have an in-depth understanding of the welcome file list. If there is not any welcome file that can be found, you will see a 404 not found error web page when you browse the Java EE web application.
  8. The index.html content should be:
        <title>This is the demo Java EE web application for</title>
        You are welcome to the demo Java EE web application for

1.2 Manually UnDeploy.

  1. It is very easy to UnDeploy a java web application manually. You just need to delete the .war file under the webapps folder.
  2. After a short moment, the extracted folder will also be deleted automatically.

2. Use Tomcat Manager To Deploy Or Undeploy.

2.1. Add A Manager Account.

  1. Browse your local apache tomcat manager URL http://localhost:8080/manager/ in a favorite web browser.
  2. If this is the first time you browse the apache tomcat manager URL, a popup dialog will let you input the user name and password.
  3. Please open the configuration file C:\Program Files\Apache Software Foundation\Tomcat 9.0\conf\tomcat-users.xml to add a new user account that can access Tomcat manager GUI.
  4. Add below tomcat user configuration data in the above file. Choose any username and password that you like and roles must be manager-gui.
    <user username="admin" password="666666" roles="manager-gui"/>

2.2 Deploy Java Web Applications.

  1. Now please browse http://localhost:8080/manager/ again and input the username and password you just added.
  2. After login, you will see the Tomcat Web Application Manager page, which lists all the deployed web applications.
  3. Now scroll the page down and go to the Deploy —> WAR file to deploy section.
  4. Click the Browse… button to select the .war file ( for example Dev2qaWebAppExample.war file ) that you want to deploy. After that click the Deploy button.
  5. Then you can find the application in the Applications list section. For example, Browse http://localhost:8080/Dev2qaWebAppExample/ to confirm that it has been deployed successfully.

2.3 Undeploy Java Web Applications.

  1. It is so easy to undeploy applications with Tomcat Manager GUI.
  2. Go to the Applications list section. Click the Undeploy button in the Commands column, then you can find it has been undeployed successfully.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.