Name

Example Application Deployment Descriptor

Synopsis

Example F-2 shows an example of a deployment descriptor (web.xml) file:

Example F-2. Example deployment descriptor file

<?xml version="1.0" encoding="ISO-8859-1"?>
  
<!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
  
<web-app>
  <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’ll find a standard XML declaration and a DOCTYPE declaration, specifying the DTD for this file. The <web-app> element then follows with 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, Second 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.