java web application deployment modes and formats

In this post, you will learn:

  • What is exploded format of a web application?
  • What is packaged format of a web application?
  • What are hot & cold deployment modes?

Understanding java web application deployment

Deployment is the process of uploading a web application on a web server in such a format that it can be managed and executed by the server. Servlet API, defines standard formats for packaging and distributing java web applications.

A Java web application can be deployed in the following two formats on a server:

  1. Exploded Format
  2. Packaged Format

In exploded format, application folder which contains application components as per the standard directory structure, is used as the deployment unit i.e. the application folder is uploaded on the server. The advantage of this approach is that after deployment when some modifications are made to the application components, these modifications are auto applied by the server on the deployed application. Usually packaged format is used during development time when frequent modifications are made to the application.

In packaged format, contents of the application folder are compressed in a Web Application Archive (WAR) file which is used as the deployment unit i.e the war file is uploaded on the server. Packaged format is used at the time of product release i.e. when the application is moved from the development server to the production server. If after deployment, application is modified, war file need to be created and deployed again to reflect changes on the server.

Creating a war file:

A war file is created with the help of jar tool which is part of JDK. To create a war file following steps are required:

  1. Arrange the application contents according to the standard directory structure.
  2. Change folder to the application folder.
  3. Use the jar command to compress the contents in a war file as follows:

jar -cf warFileName * ⏎


jar -cvf warFileName * ⏎

The -c option represents that a new jar or war file is to be created, -v option represents verbose (wordy, descriptive) execution of the jar tool i.e. the log of the compression process is to be displayed on the console, the -f option represent the name of the jar or war file to be created and the * option represents that all the files and folders of the current folder including their contents are to be compressed.

Deploying an application:

Each server supports following two modes of deployment:

  1. Hot Deployment
  2. Cold Deployment

In hot deployment, application folder or its war file is directly copied to the staging folder of the server. Staging folder is the folder which is used by the server for launching applications. The name and path of this folder differs from server to server e.g. in Tomcat the staging folder is webapps. In this approach, the application programmer need to be familiar with the server directory structure.

In cold deployment, application folder or its war file is uploaded on the server with the help of a mediator which is usually some application. For example, all servers provides admin consoles for deploying and managing applications. These consoles are web applications which provide browser (HTML) based interface to the application programmers. Tomcat manager is the application console of Tomcat. In this approach, application programmers need not be familiar with the directory structure of the server.

Its time to recap the main concepts:

  1. When web application folder is used as deployment unit it is called exploded format.
  2. When web application folder contents are compressed in a war file and the war file is used as deployment unit, it is called packaged format.
  3. jar tool is used to create war files.
  4. If application folder or its war file is directly uploaded to the server’s staging folder, it is called hot deployment.
  5. When application folder or its war file is deployed on the server with the help of an intermediary application, it is called cold deployment.
If you like the post, then share it...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *