Example Application Deployment Descriptor
Example F-2 shows an example of a deployment descriptor (web.xml) file.
<?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4> <servlet> <servlet-name> purchase </servlet-name> <servlet-class> com.mycomp.servlets.PurchaseServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name> purchase </servlet-name> <url-pattern> /po/* </url-pattern> </servlet-mapping> </web-app>
At the top of the file, you find a standard XML declaration and the
<web-app>
element, with the reference to the
deployment descriptor schema. Then follows a
<servlet>
element that defines a servlet
named purchase
, and a
<servlet-mapping>
element that maps the
servlet to the /po/* path prefix pattern.
Get JavaServer Pages, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.