Saturday, 15 March 2014

Tomcat - war file deployment

Enjoying this guide? Join our developer community!

Subscribe to Ram N Java on YouTube

How 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:

tomcat/webapps/

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:

  1. Go to the tomcat/bin/ folder.
  2. Run startup.bat (Windows) or ./startup.sh (Linux/Mac).
  3. 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:

http://localhost:8080/<your-war-filename>

For example: http://localhost:8080/displayallheaders. The landing page or servlet output will display immediately.


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






































See also:

  • Servlets Tutorial
  • All Design Patterns Links
  • No comments:

    Post a Comment

    Tutorials