O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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>!

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required