Filename extension | .war |
---|---|
Developed by | Sun Microsystems |
Container for | JSP, Java Servlet |
Extended from | JAR |
In software engineering, a WAR file (or Web application ARchive) is a JAR file used to distribute a collection of JavaServer Pages, Java Servlets, Java classes, XML files, tag libraries, static web pages (HTML and related files) and other resources that together constitute a web application.
A WAR file may be digitally signed in the same way as a JAR file in order to allow others to determine where the source code came from.
There are special files and directories within a WAR file:
Some consider web deployment using WAR files to be disadvantageous when minor changes to source code are required for dynamic environments. Each change to source code must be repackaged and deployed in development. This does not require stopping the web server if configured for runtime deployment.
Since production environments do not promote any type of fix without sufficient testing prior to deployment, In that regard, a WAR file has a distinct advantage when properties files are used to identify environment specific variables. For example, an LDAP server in a TEST environment may be something like ldaps://testauth.company.com:636. The LDAP server in a production environment is ldaps://auth.company.com:636. An external properties file would define the link with some thing like:
LINKED_PAGE=ldaps://testauth.company.com:636
The source code reads the property file to determine the target LDAP server. In this way, developers can be certain that the WAR file tested and verified is the exactly the same as that which is being promoted to production.
The following sample web.xml file demonstrates the declaration and association of a servlet:
The /WEB-INF/classes directory is on the ClassLoader's classpath. (The classpath consists of a list of locations from which .class files can be loaded and executed by the JVM.) The /WEB-INF/classes directory contains the classes associated with the web application itself.