Servlet mappings can be “fake”

The URL pattern you put into a servlet mapping can be completely made-up. Imaginary. Fake. Just a logical name you want to give clients. Clients who have no business knowing anything about the real physical structure of your web app.

With servlet mappings, you have two structures to organize: the real physical directory and file structure in which your web app resources live, and the virtual/logical structure.

The THREE types of <url-pattern> elements

  1. EXACT match

    image with no caption
  2. DIRECTORY match

    image with no caption
  3. EXTENSION match

    image with no caption

The virtual/logical structure exists simply because you SAY it exists!

The URL patterns in the DD don’t map to anything except other <servlet-name> elements in the DD.

The <servlet-name> elements are the key to servlet mapping—they match a request <url-pattern> to an actual servlet class.

Key point: clients request servlets by <url-pattern>, NOT by <servlet-name> or <servlet-class>!

Get Head First Servlets and JSP, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.