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

  • google plus

In Brief...

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.

Take our Apache Tomcat Administration for Windows Training course for free.

See the Course Outline and Register

Instructions

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 . **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

Webucator provides instructor-led training to students throughout the US and Canada. We have trained over 90,000 students from over 16,000 organizations on technologies such as Microsoft ASP.NET, Microsoft Office, XML, Windows, Java, Adobe, HTML5, JavaScript, Angular, and much more. Check out our complete course catalog.

Categories

Courses

Author: Stephen Withrow

Stephen has over 30 years' experience in training, development, and consulting in a variety of technology areas including Java, C, C++, XML, JavaScript, AJAX, Tomcat, JBoss, Oracle, and DB2. His background includes design and implementation of business solutions on client/server, Web, and enterprise platforms. Stephen is a published writer in both technical and non-technical endeavors. Stephen received an undergraduate degree in Computer Science and Physics from Florida State University.

Discuss