How to Deploy a WAR File to Apache Tomcat (Linux)

See Apache: Tips and Tricks for similar articles.

Deploying a web application to Apache Tomcat is very straightforward using a WAR (Web ARchive) file. By deploying we mean that we are placing a zipped web application in a location on the file system where Tomcat can make the web page(s) available to the world.

To learn how to deploy a WAR file to Apache Tomcat in a Linux environment, follow these 6 steps:

  1. You'll need to create a simple web site first by creating a directory and a simple JSP (Java Server Page). The instructions for accomplishing these tasks were listed in the topic Click here to learn how set default context path in Apache Tomcat (Linux). **IMPORTANT** Complete steps 1 and 2 only in the aforementioned topic. Do not create the XML file that is shown in that topic as a context descriptor is not required when deploying a WAR file. You will simply create the /DemoWebsite folder and one JSP file that is stored in /DemoWebsite. If you completed that topic in the past, then stop the Tomcat server and delete DemoWebsite.xml from CATALINA_BASE/conf/Catalina/localhost, e.g., /var/lib/Tomcat7/conf/Catalina/localhost.
  2. Open a command prompt and navigate to /DemoWebsite. You will execute the jar utility provided in the Java JDK in order to create the WAR file. The command is sudo jar -cvf DemoWebsite.war DateJSP.jsp: Build WAR file
  3. Copy the WAR file you have just created to CATALINA_HOME/webapps, e.g., /var/lib/tomcat7/webapps.
  4. Start the Tomcat server.
  5. In the address area of the browser, type http://localhost:8080/DemoWebsite/DateJSP.jsp and submit that address to the browser.
  6. The output of your JSP page will be displayed: Date JSP

Related Articles

  1. How to Start and Stop Apache Tomcat from the Command Line (Windows)
  2. How to Deploy a WAR File to Apache Tomcat (Windows)
  3. How to Start and Stop Apache Tomcat from the Command Line (Linux)
  4. How to Deploy a WAR File to Apache Tomcat (Linux) (this article)
  5. How to Run a JSP Program in Apache Tomcat (Windows)
  6. How to Check the Status of the Apache Tomcat Server (Windows)
  7. How to Deploy a Web Application Using the Apache Tomcat Manager (Windows)
  8. How to Check the Status of the Apache Tomcat Server (Linux)
  9. How to Set Default Context Path in Apache Tomcat (Windows)
  10. How to Use the autoDeploy Attribute in Apache Tomcat (Windows)
  11. How to Deploy a Web Application Using the Apache Tomcat Manager (Linux)
  12. How to List Deployed Applications Using the Apache Tomcat Manager (Windows)
  13. How to Run Multiple Instances of Apache Tomcat on One Server (Windows)
  14. How to Run a JSP Program in Apache Tomcat (Linux)
  15. How to Establish a JDBC Connection in Apache Tomcat (Windows)
  16. How to Verify Apache Tomcat Server Operation (Windows)
  17. How to Cluster in Apache Tomcat (Linux)
  18. How to Undeploy Web Applications Using the Apache Tomcat Manager (Windows)
  19. How to Set Default Context Path in Apache Tomcat (Linux)
  20. How to Use the Java Logging API in Apache Tomcat (Windows)
  21. How to Cluster in Apache Tomcat (Windows)
  22. How to Use the Java Logging API in Apache Tomcat (Linux)
  23. How to Use the autoDeploy Attribute in Apache Tomcat (Linux)
  24. How to Configure Apache Tomcat to Use MBeans (Windows)
  25. How to List Deployed Applications Using the Apache Tomcat Manager (Linux)
  26. How to Install and Configure Apache Tomcat (Windows)
  27. How to Configure Apache Tomcat to Use MBeans (Linux)