In this post, we will learn how to deploy a sample.WAR file in Tomcat using Eclipse. First things first, we will create a Java web project and then deploy it on Tomcat server.
More information on tomcat deployment at:
For more version-specific instructions on Tomcat deployment, you can replace the version number in the above URL.
Steps to install the Tomcat server on the Windows operating system:
Adding Tomcat Runtime in Eclipse IDE
Java Web Project
You can create a web project by navigating File >> New >> Other… >> Web >> Dynamic Web Project
Give the Project name of your choice, for example, MyWebProject, and click on the Next button. You can select the target runtime if you want to optimize the application for a specific server. Choose the Apache Tomcat server runtime.
Choose the context root and content directory as MyWebProject and WebContent respectively. Select the “Generate web.xml deployment descriptor option selected as shown in the picture. This option will create a deployment descriptor for the project.
Create a Servlet.
Create a servlet and add it to the project. We can also create .html files or .jsp files etc. to the project.
Start the Tomcat server.
Deploying a.WAR file
Right-click on the web project and click on Export >> War File menu option.
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 on the Finish button.
After completing the step, verify the web apps folder of the Tomcat server. The war file would be deployed.
Browse the servlet URL mapping under the project context to verify that your application is running.
That’s it, you have successfully deployed your application in Tomcat server. For manual deployment, deploying or re-deploying of war files is automatic. You can copy/overwrite the .war file, check your web apps folder for an extracted folder.