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

A servlet can have THREE names

A servlet has a file path name, obviously, like classes/registration/SignUpServlet.class (a path to an actual class file). The original developer of the servlet class chose the class name (and the package name that defines part of the directory structure), and the location on the server defines the full path name. But anyone who deploys the servlet can also give it a special deployment name. A deployment name is simply a secret internal name that doesn’t have to be the same as the class or file name. It can be the same as the servlet class name (registration.SignUpServlet) or the relative path to the class file (classes/registration/SignUpServlet.class), but it can also be something completely different (like EnrollServlet).

Finally, the servlet has a public URL name—the name the client knows about. In other words, the name coded into the HTML so that when the user clicks a link that’s supposed to go to that servlet, this public URL name is sent to the server in the HTTP request.

  1. image with no caption

    Client-known URL name

    The client sees a URL for the servlet (in the HTML), but doesn’t really know how that servlet name maps to real directories and files back on the server. The public URL name is a fake name, made up for clients.

  2. image with no caption

    Deployer-known secret internal name

    The deployer ...

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