Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Content and structure  





2 Advantages of WAR files  





3 Disadvantages of WAR files  





4 Example  





5 See also  





6 References  





7 External links  














WAR (file format)






Deutsch
Español
Français

Italiano
Magyar

Português
Русский

 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 

(Redirected from WAR file format (Sun))

Web ARchive
Filename extension
.war
Internet media typeapplication/java-archive
Magic numberPK\x03\x04 (standard ZIP file)
Developed bySun Microsystems
Container forJSP, Java Servlet
Extended fromJAR

Insoftware engineering, a WAR file (WebApplication Resource[1]orWeb application ARchive[2]) is a file used to distribute a collection of JAR-files, 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.

Content and structure[edit]

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:

Advantages of WAR files[edit]

Assuming production environments do not promote a fix without sufficient testing prior to deployment, a WAR file has a distinct advantage when properties files are used to identify environment specific variables. For example, an LDAP server in a testing environment may be something like ldaps://testauth.example.com:636. The LDAP server in a production environment is ldaps://auth.example.com:636. An external properties file would define the link with some thing like:

LINKED_PAGE=ldaps://testauth.example.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 exactly the same as that which is being promoted to production.

Disadvantages of WAR files[edit]

Some[who?] 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.[3] This does not require stopping the web server if configured for runtime deployment.[4]

Example[edit]

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

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
    <servlet>
        <servlet-name>HelloServlet</servlet-name>
        <servlet-class>mypackage.HelloServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>HelloServlet</servlet-name>
        <url-pattern>/HelloServlet</url-pattern>
    </servlet-mapping>

    <resource-ref>
        <description>
            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.
        </description>
        <res-ref-name>mail/Session</res-ref-name>
        <res-type>javax.mail.Session</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
</web-app>

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.

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

See also[edit]

References[edit]

  1. ^ Crossley, Allistair. "Apache Tomcat 8 (8.0.44) - Tomcat Web Application Deployment". Apache Software Foundation. Retrieved 2017-06-27.
  • ^ Hunter, Jason (1999-10-15). "What's New in Java Servlet API 2.2?". JavaWorld. Retrieved 2020-11-08.
  • ^ "Web Application Lifecycle". The Java EE 6 Tutorial. Oracle.
  • ^ "Deploying on a running Tomcat server". Apache Software Foundation.
  • External links[edit]


    Retrieved from "https://en.wikipedia.org/w/index.php?title=WAR_(file_format)&oldid=1224976648"

    Categories: 
    Archive formats
    Java enterprise platform
    Hidden categories: 
    Articles with short description
    Short description is different from Wikidata
    All articles with specifically marked weasel-worded phrases
    Articles with specifically marked weasel-worded phrases from May 2024
    Webarchive template wayback links
     



    This page was last edited on 21 May 2024, at 16:40 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki