Chapter 05 - Structure and Deployment

This web application helps you play with the URL to servlet mapping. The servlet-class for all the servlets is chapter5.TestServlet. It prints out the context path, servlet path, and path info on the browser. You should try out various combinations of servlet path and path info as explained in section 5.2.4. Here are some URLS that show how the mappings work:
/chapter05/red
/chapter05/red/
/chapter05/red/aaa
/chapter05/red/blue/aa
/chapter05/red/red/aaa
/chapter5/aa.col

The deployment descriptor of this application contains the following servlets and servlet mappings:

  <servlet>
    <servlet-name>RedServlet</servlet-name>
    <servlet-class>chapter5.TestServlet</servlet-class>
  </servlet>

  <servlet>
    <servlet-name>BlueServlet</servlet-name>
    <servlet-class>chapter5.TestServlet</servlet-class>
  </servlet>

  <servlet>
    <servlet-name>GreenServlet</servlet-name>
    <servlet-class>chapter5.TestServlet</servlet-class>
  </servlet>

  <servlet>
    <servlet-name>RedBlueServlet</servlet-name>
    <servlet-class>chapter5.TestServlet</servlet-class>
  </servlet>

  <servlet>
    <servlet-name>ColorServlet</servlet-name>
    <servlet-class>chapter5.TestServlet</servlet-class>
  </servlet>


   <servlet-mapping>
      <servlet-name>RedServlet</servlet-name>
      <url-pattern>/red/*</url-pattern>
   </servlet-mapping>

   <servlet-mapping>
      <servlet-name>RedServlet</servlet-name>
      <url-pattern>/red/red/*</url-pattern>
   </servlet-mapping>

   <servlet-mapping>
      <servlet-name>RedBlueServlet</servlet-name>
      <url-pattern>/red/blue/*</url-pattern>
   </servlet-mapping>

   <servlet-mapping>
      <servlet-name>BlueServlet</servlet-name>
      <url-pattern>/blue/</url-pattern>
   </servlet-mapping>

   <servlet-mapping>
      <servlet-name>GreenServlet</servlet-name>
      <url-pattern>/green</url-pattern>
   </servlet-mapping>

   <servlet-mapping>
      <servlet-name>ColorServlet</servlet-name>
      <url-pattern>*.col</url-pattern>
  </servlet-mapping>