We can even do the same thing for external web components. The included web component inside a web application is called web fragment. To declare a web fragment, we need to put the web-fragment.xml descriptor file in an external JAR archive. Here's a sample that declares a filter:
<web-fragment version="3.1"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<filter>
<filter-name>LoggingFilter</filter-name>
<filter-class>it.vige.webprogramming.servletjsp.filters.LoggingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LoggingFilter</filter-name>
...