Enjoying this guide? Join our developer community!
Subscribe to Ram N Java on YouTubeHow to Deploy a WAR File in Apache Tomcat (Webapps Directory Method)
The simplest and most direct way to deploy a Java web application on Apache Tomcat is using the webapps folder. When Tomcat starts up, it automatically detects, extracts, and deploys any packaged WAR (Web Application Archive) file placed inside this directory.
Step 1: Locate Your WAR File
Build or locate your compiled WAR file on your computer (for example, on your Desktop or target build folder).
- The name of the WAR file determines the context path of your web application.
- For example, if your file is named
displayallheaders.war, your application will run under/displayallheaders.
Step 2: Copy the WAR File to the Webapps Directory
Navigate to your Apache Tomcat installation directory and open the webapps folder:
Paste your .war file directly into this folder.
Step 3: Start the Apache Tomcat Server
Start Tomcat so that it can unpack the archive and initialize the application context:
- Go to the
tomcat/bin/folder. - Run
startup.bat(Windows) or./startup.sh(Linux/Mac). - Watch the console output to confirm that Tomcat creates an unpacked folder for your application and starts successfully.
Step 4: Verify and Access the Application
Open your web browser and navigate to the application URL:
For example: http://localhost:8080/displayallheaders. The landing page or servlet output will display immediately.
Recommended Related Tutorials from Ram N Java
Click here to watch in Youtube : https://www.youtube.com/watch?v=jZL33Hggf-I
To Download the Sample war file Click the below link:
https://sites.google.com/site/javaee4321/servlets/DisplayAllHeaders.war?attredirects=0&d=1
Click the below Image to Enlarge
| Tomcat - war file deployment |
| Tomcat - war file deployment |
| Tomcat - war file deployment |
No comments:
Post a Comment