Java Reference
In-Depth Information
Table 23.3 Contents of the WAR file
Name
Type
Content
text
A standard JAR manifest; it can be empty or list the
contents.
MANIFEST.MF
XML
XML description of the Web application—servlet
definitions, and so on.
web.xml
XML
Empty in our example—no JBoss-specific directives
are used.
jboss-web.xml
directory
Directory structure for the Java class files.
classes
class
The various class files.
classes/.../*.class
JSP
These are the JSP files that run as part of the Web
application; note that they are in the top level of this
directory structure, not in any subdirectory.
*.jsp
HTML
Any static HTML pages, too.
*.html
directory
A directory with other files.
META-INF
directory
A directory with other files.
WEB-INF
23.2.3.2
The web.xml file is the descriptor for the Web application part of all this.
Using the servlet tag, it defines a servlet associating a name with this servlet
(a name which can be used elsewhere in this XML file) and stating which
Java class file is that servlet.
Then the servlet-mapping tag is used to map a URL pattern to a servlet.
The URL pattern is the portion of the URL that signals to the server that the
request is not for a simple HTML page, but rather for our servlet.
Example 23.6 is a sample web.xml ; notice in particular how the mapping
from URLs to the Java class is accomplished.
Weaving the Web
23.2.3.3
So now that you have seen all the pieces, know that you can edit the XML files
with your favorite editor, and can build the JAR/WAR/EAR files with the jar
command, it's not that hard to put it all together. It is, however, tedious, and
is well worth automating, at least with Ant.
The key to making it work, whether by hand or by automation, is a
workable directory structure. The easiest way to construct JAR files is to have
Connecting the Pieces
Search WWH ::




Custom Search