Java web applications are distributed in WAR (Web application Archive) files. A WAR file is a compressed file that keeps the structure of web applications (apart from the web application context directory, which is the application's top directory), and includes one extra folder named META-INF
. These compressed files have a .war
extension. The META-INF
folder contains metadata about the files within a WAR file. An important file kept in this folder is the MANIFEST.MF
file. Among other things, such a special file has information about the files packaged in a WAR file.
When WAR files are deployed, they are unpacked by the container, which creates the structure shown in the following figure. The name of the top directory depends on the container in question. Tomcat, for instance, names the top directory after the WAR file. So, for instance, the following structure would be created by Tomcat upon unpacking a deployedapp.war
file. As you can see, the internal structure of a WAR file is pretty much the same as the structure of your Eclipse dynamic web project:
To create a WAR file from your project, right-click on the project and select Export. Select the WAR file option as shown in the next screenshot, specify the target directory through the button Browse… and hit Finish. Now you can deploy your WAR file to Tomcat by placing it under the webapp
directory and restarting the container.