4.3 Deploying Web Applications in WAR Files
WAR (Web ARchive) files provide a convenient way of bundling Web apps in a single file. Having a single large file instead of many small files makes it easier to transfer the Web application from server to server.
A WAR file is really just a JAR file with a .war extension, and you use the normal jar command to create it. For example, to bundle the entire widgetStore Web app into a WAR file named widgetStore.war, you would just change directory to the widgetStore directory and execute the following command.
jar cvf widgetStore.war *
For simple WAR files, that's it! However, in version 2.3 of the servlet API, you can create WAR files that designate that they need shared but nonstandard libraries installed on the server. This topic is covered in Section 4.4.
Of course, you can use other jar options (e.g., to digitally sign classes) with WAR files just as you can with regular JAR files. For details, see http://java.sun.com/j2se/ 1.3/docs/tooldocs/win32/jar.html (Windows) or http://java.sun.com/j2se/1.3/docs/tool-docs/solaris/jar.html (Unix/Linux).
Finally, remember that you have to follow slightly different procedures to register Web apps that are contained in WAR files than you do to deploy unbundled Web applications. For details, see Section 4.1 (Registering Web Applications).