Web application ARchive
lastmod 2018-08-17created 2015-04-175 edits
In software engineering, a WAR file (or Web application ARchive1) 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.
META_INF vs WEB-INF
ETA-INF is part of jar, the Java packaging technology. A jar basically has the same file format as zip, but it defines additional conventions beyond zip, one of which is the format and purpose of the META-INF directory and some files in it. WEB-INF, on the other hand, is a directory created separately for web applications (by the servlet specification). The reason to put Spring configuration files in META-INF is that the application can then be packaged and distributed as a jar rather than a war. Usually, if you build an application as a multi-tier architecture and plan to package each tier separately, the metadata of tiers unrelated to the web should go in META-INF, not WEB-INF.
Structure of a WAR file
document root
- JSP pages
- client-side classes
- archives
- static Web resources
- /WEB-INF
- /WEB-INF/web.xml
- Defines the structure of the web application: declares the URLs to route to when servlets are included, defines context values referenced by servlets
- /WEB-INF/web.xml
- The ClassLoader's classpath. .class files here are loaded when the web application runs.
- JAR files here are placed on the ClassLoader's classpath.