Site icon TestingDocs.com

How to deploy a .WAR file in Tomcat using Eclipse?

Introduction

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 the Tomcat server.

Tomcat Install

Steps to install the Tomcat server on the Windows operating system:

https://www.testingdocs.com/apache-tomcat-server-install-on-windows/

Adding Tomcat Runtime in Eclipse IDE

https://www.testingdocs.com/install-apache-tomcat-using-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.

( http://www.testingdocs.com/questions/how-to-create-a-sample-servlet-using-eclipse/ )

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.

Screenshot

 

That’s it, you have successfully deployed your application on the 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.

More information on tomcat deployment at:

https://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html

For more version-specific instructions on Tomcat deployment, you can replace the version number in the above URL.

Exit mobile version