![]() |
VOOZH | about |
A war (web archive) A web project's files are contained in this file. It may contain files such as servlet, xml, jsp, image, html, css, and js. Here, we'll go through what a war file is, how to make one, how to deploy one, and how to remove one.
The WAR file (Web Application Resource or Web Application ARchive) is a container for JAR files, JavaServer Pages, Java Servlets, Java classes, XML files, tag libraries, static sites (HTML and associated files), and other resources that make up an online application. A file entitled web.xml is located in the /WEB-INF directory of the WAR file, and it describes the structure of the online application. The web.xml file isn't technically essential if the online application is only providing JSP files. If the online apps utilize servlets, the servlet container looks at web.xml to figure out which servlet a URL request should go to.
On the command prompt, type the following command to generate a war file:
jar -cvf project_name.war*
Here,
Example – D:\apps\gfgapp>jar -cvf testapp1.war*
There are two ways to deploy the WAR File:
Steps to be followed:
Set up your Tomcat server to run as a service (optional), If you wish to manually deploy the war file in Apache Tomcat, navigate to the web app's directory and paste the war file there.
The following is the syntax for extracting the WAR file:
jar -xvf project_name.war*
Here, -x: It is a switch of jar tool of JDK