2.4. Packaging Servlets

In a production environment, multiple programmers may be developing servlets for the same server. So, placing all the servlets in the top-level servlet directory results in a massive hard-to-manage directory and risks name conflicts when two developers accidentally choose the same servlet name. Packages are the natural solution to this problem. Using packages results in changes in the way the servlets are created, the way that they are compiled, and the way they're invoked. Let's take these areas one at a time in the following three subsections. The first two changes are exactly the same as with any other Java class that uses packages; there is nothing specific to servlets.

Creating Servlets in Packages

Two steps are needed ...

Get Core Servlets and JavaServer Pages™ now with O’Reilly online learning.

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