WEB APPLICATION ARCHIVES


WAR file developed by Sun Microsystem, pretty similar to JAR(Java archive File) act as containers with robust folder structure containing all the files and goodies needed to run a web application .WAR file represents a web application which can run on a server,web clients are packaged into this.Web Application archives consist of server side utility classes such as java bean, database and carts, client side classes such as applets and static contents such as HTML files, Images,sound files etc in addition to various Web Components.



The static components in the web application archives are also refered as web resources.The web application archives follows a strict directory structure. Root is the top level directory of web application archive files,it is here where the jsp pages,client side classes (applets),archives and web resources like HTML, Images, Property files are stored.


WEB-INF is a sub directory of Root. It contains


  • TLD( Tag Library Descriptors) which is XML file describing tags used in JSP files.

  • Server side classes such as beans,servlets and utility classes are stored in sub directory classes.

  • The java archive files (JAR) and other utility library used by server side classes are stored in sub directory lib.This is a general directory structure of WAR developers can also creates specific sub-directory packages in root or WEB-INF

  • Web application deployment descriptor which is web.xml file.


Creating Web Application Archive File


The deploy tool automatically creates war file while you add a new component to the web application.

WAR file can also be created by


  • Packager Tool which is a command line script that enables developer to package web components.It can also be used to make JAR, RAR, EAR other than WAR File

  • Portable Build tool ant can be used to build WAR files using war tasks within it.

  • If the application file is structured in the format of the web application archive file structure you can use JAR tool by executing command “jar cvf MyApps.war” The web.xml should also be created in correct format while using above methods to create WAR files manually.



One of the shortcomings of WAR is that when using it in a very dynamic scenario such as at the time of vigorous testing, there arises some cases of frequent change in the files.But these changes cannot be made during run time.In such cases the WAR file should be redeployed and regenerated with newly updated files.



Developer facing such scenarios can use JEE containers, also known as explode archives, which allows the web application to be deployed as directory structure instead of single file.