Java Reference
In-Depth Information
Example 18−11: web.xml (continued)
<servlet-name>queryOtherDatabase</servlet-name>
<servlet-class>com.davidflanagan.examples.servlet.Query</servlet-class>
<!-- Add init params here, or this servlet won't work right -->
</servlet>
<servlet> <!-- The logout servlet -->
<servlet-name>logout</servlet-name>
<servlet-class>com.davidflanagan.examples.servlet.Logout</servlet-class>
</servlet>
<!-- A servlet mapping specifies URL prefixes or suffixes that cause a -->
<!-- particular named servlet to be invoked. This one specifies that any -->
<!-- URL ending with ".count" will invoke the "counter" servlet -->
<servlet-mapping>
<servlet-name>counter</servlet-name> <!-- A name from a <servlet> tag -->
<url-pattern>*.count</url-pattern>
<!-- What URLs invoke it -->
</servlet-mapping>
<!-- This tag specifies session management information for our webapp -->
<session-config>
<session-timeout>15</session-timeout> <!-- timeout after 15 minutes idle-->
</session-config>
<!-- Mapping information about the tag libraries used in the webapp -->
<taglib>
<!-- When you see this unique identifier for a tag library... -->
<taglib-uri>http://www.davidflanagan.com/tlds/decor_0_1.tld</taglib-uri>
<!-- ...use this local copy of the Tag Library Descriptor file -->
<taglib-location>tlds/decor_0_1.tld</taglib-location>
</taglib>
</web-app>
Packaging Web Applications into WAR Files
As of Version 2.2 of the servlet specification, web applications can be portably dis-
tributed in WAR archives. A WAR archive is simply a JAR file that contains specific
information for a web application, most notably the WEB-INF/web.xml file. Both
the WAR and JAR archive formats use the standard ZIP archiving and compression
format.
The root directory of the WAR archive and all of its subdirectories, except the
WEB-INF directory, contain user-visible files the web server may display to the
user. For example, you might place a static index.html file for your web applica-
tion in the root directory. If the web application requires a lot of static content,
you might want to organize it in subdirectories, such as an images/ directory.
The root directory (and its subdirectories) is also where JSP pages are placed. The
web server does not treat these as static files but defers them to the JSP container.
If your application has a default index.jsp file, it should go here.
The /WEB-INF/ directory contains WEB application configuration INFormation and
the Java classes needed to make the application run. As you've already seen, the
/WEB-INF/web.xml file is the main deployment descriptor for the application.
Search WWH ::




Custom Search