![]() | MSc-IT Study Material June 2010 Edition Computer Science Department, University of Cape Town |
Since the Servlet API 2.2 specification, every Servlet aware Web server is required to accept Web applications in a standard format. A Servlet Web application is defined as a collection of directories and files, all of which can possibly be compressed into a single file called a Web application archive (WAR). These WAR files are a useful way to distribute your Web application once you have written it, but we will not be covering them in these notes.
The Servlet specification defines in what directories various files making up the application should be placed. If our Web application is stored in a directory called APPLICATION, then the various files should be laid out as follows:
HTML files are stored directly in the APPLICATION directory.
The APPLICATION/Web-INF directory contains metadata about the Web application itself, and the various Servlets which make up the application. This metadata is stored in the APPLICATION/Web-INF/web.xml file.
APPLICATION/Web-INF/classes contains the class files implementing the various Servlets.
APPLICATION/Web-INF/lib contains any JAR files the application uses.
All of the following examples use the layout described above.