13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

23.2 Lend Me Your EAR: Enterprise Packaging and Deployment513Table 23.3 C<strong>on</strong>tents of the WAR fileNameMANIFEST.MFweb.xmljboss-web.xmlclassesclasses/.../*.class*.jsp*.htmlMETA-INFWEB-INFTypetextXMLXMLdirectoryclassJSPHTMLdirectorydirectoryC<strong>on</strong>tentA standard JAR manifest; it can be empty or list thec<strong>on</strong>tents.XML descripti<strong>on</strong> of the Web applicati<strong>on</strong>—servletdefiniti<strong>on</strong>s, and so <strong>on</strong>.Empty in our example—no JBoss-specific directivesare used.Directory structure for the Java class files.The various class files.These are the JSP files that run as part of the Webapplicati<strong>on</strong>; note that they are in the top level of thisdirectory structure, not in any subdirectory.Any static HTML pages, too.A directory with other files.A directory with other files.23.2.3.2 Weaving the WebThe web.xml file is the descriptor for the Web applicati<strong>on</strong> 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 whichJava 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 porti<strong>on</strong> of the URL that signals to the server that therequest 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 mappingfrom URLs to the Java class is accomplished.23.2.3.3 C<strong>on</strong>necting the PiecesSo now that you have seen all the pieces, know that you can edit the XML fileswith your favorite editor, and can build the JAR/WAR/EAR files with the jarcommand, it’s not that hard to put it all together. It is, however, tedious, andis well worth automating, at least with Ant.The key to making it work, whether by hand or by automati<strong>on</strong>, is aworkable directory structure. The easiest way to c<strong>on</strong>struct JAR files is to have

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!