The Servlet 3.0 specification contains the new @WebServlet annotation, which can be used to declare servlets in code without the need for web.xml. For more information, see Section 8.1.1 of the Servlet 3.0 Specification and view javadoc .
@WebServlet("/myServlet") public class MyServlet extends HttpServlet {
In addition, Servlet 3.0 introduced the concept of web fragments, which addresses your second issue of splitting web.xml into multiple files. These fragments may contain part (or all) of the web deployment descriptor, including annotations of the META-INF/web-fragment.xml file and / or servlet in the jar files in the directory of your WEB-INF/lib web module. For more information, see Section 8.2 of the Servlet 3.0 Specification.
source share