Servlet Tutorials

War File
Previous Home Next
adplus-dvertising

In war (web archive) File can be defines as it contains files of a web project and servlet, xml, jsp, image, html, css, js etc. files.

Then we have discuss what is war file, why to create war file, how to deploy war file and how to extract war file.

What is war file?

In the web archive (war) file which contains all the contents of a web application and reduces the time duration for transferring file.

Advantage

saves time:It is jioned to all the files into a single unit from client to server.

How to create war file?

Create a war file, we can need to use jar tool of JDK which can be need to use -c switch of jar, to create the war file.

And we can go inside the project directory of the project (outside the WEB-INF),uesd command:

jar -cvf projectname.war *

This -c is used to create file, -v to generate the verbose output and -f to specify the arhive file name.

The * (asterisk) symbol is used for all the files of this directory.

How to deploy the war file?

Two ways to deploy the war file as follows.

By server console panel

By manually having the war file in specific folder of server.

We want to deploy the war file in apache tomcat server manually, then we go to the webapps directory of apache tomcat and paste the war file here.

Now,we can able to access the web project through browser.

Note: server will extract the war file internally.

How to extract war file manually?

It is extract the war file, we used a -x switch of jar tool of JDK and used command to extract the war file.

jar -xvf projectname.war
Previous Home Next