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

Mapping the logical name to a servlet class file

  1. Diane fills out the form and hits submit. The browser generates the request URL:

    image with no caption
  2. The Container searches the DD and finds a <servlet-mapping> with a <url-pattern> that matches /SelectBeer.do, where the slash (/) represents the context root of the web app, and SelectBeer.do is the logical name of a resource.

    image with no caption
  3. The Container sees that the <servlet-name> for this <url-pattern> is “Ch3 Beer”. But that isn’t the name of an actual servlet class file. “Ch3 Beer” is the name of a servlet, not a servlet class!

    To the Container, a servlet is something named in the DD under a <servlet> tag. The name of the servlet is simply the name used in the DD so that other parts of the DD can map to it.

  4. The Container looks inside the <servlet> tags for something with the <servlet-name> “Ch3 Beer”.

    image with no caption
  5. The Container uses the <servlet-class> in the <servlet> tag to know which servlet class is responsible for handling this request. If the servlet has not been initialized, the class is loaded and the servlet is initialized.

  6. The Container starts a new thread to handle the request, and passes the request to the thread (to the servlet’s service() method).

  7. The Container sends the ...

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