In Eclipse, I create a dynamic web project ( Dynamic web module version 3.0 ), tick automatic generation of web.xml . I create a servlet where servlet mapping specified.
The servlet starts, everything is fine, everyone is happy, except that web.xml itself is empty (well, not completely empty, but servlets are not marked there). In the project itself there is a Deployment descriptor: ServletProject , where servlets and filters Deployment descriptor: ServletProject out just the same. In addition to this, an annotation of the form @WebServlet("/ServletName") added to the servlet itself.

Actually 2 questions:

  1. How to make everything related to servlets generated in web.xml ?
  2. Why does Eclipse do this? What are the pros / cons?

    1 answer 1

    These annotations were introduced as part of the Servlet API 3.0 for (in particular) moving the servlet configuration from web.xml closer to the corresponding classes. Perhaps there are other advantages besides facilitating web.xml , I don’t know about them.

    It seems that the settings in Eclipse for generating mappings in web.xml for projects using the Servlet API 3.0 are not.