Mapping the logical name to a servlet class file
Diane fills out the form and hits submit. The browser generates the request URL:

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.

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.
The Container looks inside the <servlet> tags for something with the <servlet-name> “Ch3 Beer”.

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.
The Container starts a new thread to handle the request, and passes the request to the thread (to the servlet’s service() method).
The Container sends the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access