World Library  
Flag as Inappropriate
Email this Article

WAR (file format)

Article Id: WHEBN0003294583
Reproduction Date:

Title: WAR (file format)  
Author: World Heritage Encyclopedia
Language: English
Subject: PeaZip, Mura CMS, War (disambiguation), Zoo (file format), CFS (file format)
Collection: Archive Formats, Java Enterprise Platform
Publisher: World Heritage Encyclopedia
Publication
Date:
 

WAR (file format)

Web ARchive
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[1]) is a JAR file used to distribute a collection of JavaServer Pages, Java Servlets, Java class (file format)es, XML files, tag libraries, static web pages (HTML and related files) and other resources that together constitute a web application.

Contents

  • Content and structure 1
  • Advantages of WAR files 2
  • Disadvantages of WAR files 3
  • Example 4
  • See also 5
  • References 6
  • External links 7

Content and structure

A WAR file may be digitally signed in the same way as a JAR file in order to allow others to determine what source the code came from.

There are special files and directories within a WAR file:

  • The /WEB-INF directory in the WAR file contains a file named web.xml which defines the structure of the web application. If the web application is only serving JSP files, the web.xml file is not strictly necessary. If the web application uses servlets, then the servlet container uses web.xml to ascertain to which servlet a URL request will be routed. web.xml is also used to define context variables which can be referenced within the servlets and it is used to define environmental dependencies which the deployer is expected to set up. An example of this is a dependency on a mail session used to send email. The servlet container is responsible for providing this service.

Advantages of WAR files

  • Easy testing and deployment of web applications
  • Easy identification of the version of the deployed application
  • All Java EE containers support WAR files

Disadvantages of WAR files

One disadvantage of web deployment using WAR files (especially in very dynamic environments) stems from the restriction that minor changes cannot be made during runtime. Any change whatsoever requires regenerating and redeploying the entire WAR file.

Example

The following sample web.xml file demonstrates the declaration and association of a servlet:

 
 
 
 
     
         HelloServlet
         mypackage.HelloServlet
     
 
     
         HelloServlet
         /HelloServlet
     
 
     
         
             Resource reference to a factory for javax.mail.Session
             instances that may be used for sending electronic mail messages,
             preconfigured to connect to the appropriate SMTP server.
         
         mail/Session
         javax.mail.Session
         Container
     
 

The /WEB-INF/classes directory is on the ClassLoader's classpath. This is where .class files load from when the web application executes.

Any JAR files placed in the /WEB-INF/lib directory will also be placed on the ClassLoader's classpath.

See also

Related file formats:

References

  1. ^ "What's New in Java Servlet API 2.2?".  

External links

  • Oracle Java EE 7 Tutorial: Packaging Web Archives
  • Oracle Java EE 6 Tutorial: Web Modules
  • Oracle Java EE 5 Tutorial: Web Modules
  • WAR file informations File Extension WAR
  • Sun Microsystems: XML Schema for the Servlet 2.5 Web ARchive (WAR) File
  • Sun Microsystems: XML Schema for the Servlet 2.4 Web ARchive (WAR) File
  • JSR 154: Java Servlet 2.4 Specification
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 


Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.