Standard Java EE web applications are deployed as WAR files or exploded (unarchived) web application directories. All Java EE web application servers support WAR file application archives. Whether archived or exploded, the directory structure convention, as shown in Figure is the same.

Directory Structure

  • This structure contains classes and other application resources, the class files live in /WEB-INF/classes. The WEB-INF directory stores informational and instructional files that Java EE web application servers use to determine how to deploy and run the application. Its classes directory acts as the package root. All compiled application class files and other resources live within this directory.

  • WAR files can contain bundled JAR files, which live in /WEB-INF/lib. All the classes in the JAR files in this directory are also available to the application on the application’s classpath.

  • The /WEB-INF/tags and /WEB-INF/tld directories are reserved for holding JSP tag files and tag library descriptors, respectively.

  • The i18n directory is not actually part of the Java EE specifications, but it is a convention that most application developers follow for storing internationalization (i18n) and localization (L10n) files.

  • There are two different META-INF directories.

    • The root-level /META-INF directory contains the application manifest file. This directory is not on the application classpath. You cannot use the ClassLoader to obtain resources in this directory. It contains resources for specific web containers or application servers. For example, Apache Tomcat looks for and uses a context.xml file in this directory to help customize how the application is deployed in Tomcat. None of these files are part of the Java EE specification, and the supported files can vary from one application server or web container to the next.

    • WEB-INF/classes/META-INF is on the classpath. Any application resources you desire in this directory, and they become accessible through the ClassLoader. Some Java EE components specify files that belong in this directory. For example, the Java Persistence API specifies two files, persistence.xml, and orm.xml — that live in /WEB-INF/classes/META-INF.

Most files contained within a WAR file or exploded web application directory are resources directly accessible through a URL. For example, the file /bar.html relative to the root of an application deployed to _http://example.org/foo_ is accessible from _http://example.org/foo/bar.html_.

In the absence of any filter or security rules to the contrary, this holds true for all resources in your application except those resources under the /WEB-INF and /META-INF directories. The files in these directories are protected resources that are not accessible via URL.