{"id":942,"date":"2018-05-12T09:07:09","date_gmt":"2018-05-12T09:07:09","guid":{"rendered":"http:\/\/www.testingdocs.com\/questions\/?p=942"},"modified":"2025-05-16T07:42:35","modified_gmt":"2025-05-16T07:42:35","slug":"how-to-deploy-a-war-file-in-tomcat-using-eclipse","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/how-to-deploy-a-war-file-in-tomcat-using-eclipse\/","title":{"rendered":"How to deploy a .WAR file in Tomcat using Eclipse [ 2024 ]"},"content":{"rendered":"<h2>How do you deploy a WAR file in Tomcat using Eclipse?<\/h2>\r\n<p>This post will teach you how to use Eclipse to deploy a sample WAR file in Tomcat. First, we will create a Java web project and then deploy it on the Tomcat server.<\/p>\r\n<p>A <strong data-start=\"2\" data-end=\"36\">.war (Web Application Archive)<\/strong> file is a packaged file format used to distribute Java-based web applications, containing servlets, JSP files, HTML, and other resources needed to run the application on a server like Apache Tomcat. It simplifies deployment by bundling all components into a single archive.<\/p>\r\n<h2>Tomcat Install<\/h2>\r\n<p>Steps to install the Tomcat server on the Windows operating system:<\/p>\r\n<ul>\r\n<li><a href=\"https:\/\/www.testingdocs.com\/apache-tomcat-server-install-on-windows\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.testingdocs.com\/apache-tomcat-server-install-on-windows\/<\/a><\/li>\r\n<\/ul>\r\n<h2>Adding Tomcat Runtime in Eclipse IDE<\/h2>\r\n<ul>\r\n<li><a href=\"https:\/\/www.testingdocs.com\/install-apache-tomcat-using-eclipse-ide\/\">https:\/\/www.testingdocs.com\/install-apache-tomcat-using-eclipse-ide\/<\/a><\/li>\r\n<\/ul>\r\n<h2><strong>Java Web Project<\/strong><\/h2>\r\n<p>You can create a web project by navigating <strong>File &gt;&gt; New &gt;&gt; Other&#8230; &gt;&gt; Web &gt;&gt; Dynamic Web Project<\/strong><\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-856\" src=\"http:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-Web-Project.png\" alt=\"Java Web Project\" width=\"857\" height=\"756\" title=\"\"><\/p>\r\n<p>Give the Project name of your choice, for example, <strong>MyWebProject,<\/strong> and click on the Next button. You can select the target runtime to optimize the application for a specific server.\u00a0 Choose the Apache Tomcat server runtime.<\/p>\r\n<p>Choose the context root and content directory as <strong>MyWebProject<\/strong> and <strong>WebContent,<\/strong> respectively. Select the &#8220;Generate web.xml deployment descriptor option as shown in the picture. This option will create a deployment descriptor for the project.<\/p>\r\n<p>&nbsp;<\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-858\" src=\"http:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Web-Module-Settings.png\" alt=\"Web Module Settings\" width=\"897\" height=\"764\" title=\"\"><\/p>\r\n<h2><strong>Create a Servlet<\/strong><\/h2>\r\n<p>Create a servlet and add it to the project. We can also create .html files or .jsp files etc. for the project.<\/p>\r\n<ul>\r\n<li><a href=\"http:\/\/www.testingdocs.com\/questions\/how-to-create-a-sample-servlet-using-eclipse\/\">http:\/\/www.testingdocs.com\/questions\/how-to-create-a-sample-servlet-using-eclipse\/<\/a>\u00a0<\/li>\r\n<\/ul>\r\n<p>Start the Tomcat server.<\/p>\r\n<p>&nbsp;<\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-861\" src=\"http:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Start-Tomcat-Server-from-Eclipse.png\" alt=\"Start Tomcat Server\" width=\"1365\" height=\"695\" title=\"\"><\/p>\r\n<h2><strong>Deploying a.WAR file<\/strong><\/h2>\r\n<p>Right-click on the web project and click <strong>Export &gt;&gt; War<\/strong> File menu option.<\/p>\r\n<p>Choose the WAR file export settings to deploy the .war file in Tomcat. Select the web project, destination folder, target runtime, and other options, and click the Finish button.<\/p>\r\n<p>&nbsp;<\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-862\" src=\"http:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/WAR-File.png\" alt=\".WAR File\" width=\"858\" height=\"573\" title=\"\"><\/p>\r\n<p>&nbsp;<\/p>\r\n<p>After completing the step, verify the <strong>web apps<\/strong> folder of the Tomcat server. The war file would be deployed.<\/p>\r\n<p>&nbsp;<\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-863\" src=\"http:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Tomcat-deployment.png\" alt=\"Tomcat deployment\" width=\"1018\" height=\"599\" title=\"\"><\/p>\r\n<p>&nbsp;<\/p>\r\n<p>Browse the servlet URL mapping under the project context to verify that your application is running.<\/p>\r\n<h2>Screenshot<\/h2>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-864\" src=\"http:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Servlet-Running.png\" alt=\"Servlet Running\" width=\"1365\" height=\"625\" title=\"\"><\/p>\r\n<p>&nbsp;<\/p>\r\n<p>That&#8217;s it, you have successfully deployed your application on the Tomcat server. For manual deployment, deploying or re-deploying war files is automatic. You can copy\/overwrite the .war file, check your web apps folder for an extracted folder.<\/p>\r\n<p>More information on tomcat deployment at:<\/p>\r\n<ul>\r\n<li><strong> https:\/\/tomcat.apache.org\/tomcat-6.0-doc\/deployer-howto.html<\/strong><\/li>\r\n<\/ul>\r\n<p>You can replace the version number in the above URL for more version-specific instructions on Tomcat deployment.<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>How do you deploy a WAR file in Tomcat using Eclipse? This post will teach you how to use Eclipse to deploy a sample WAR file in Tomcat. First, we will create a Java web project and then deploy it on the Tomcat server. A .war (Web Application Archive) file is a packaged file format [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-942","post","type-post","status-publish","format-standard","hentry","category-automation","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=942"}],"version-history":[{"count":16,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/942\/revisions"}],"predecessor-version":[{"id":27332,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/942\/revisions\/27332"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}