private static Set<String> getUrlPatterns( String type, Document webXml, String typeName )
    {
        Log.trace("Looking for URL patterns for {} '{}'", type, typeName);
        final Set<String> result = new HashSet<>();
        final List<Element> elements = webXml.getRootElement().elements( type + "-mapping" ); // all elements of 'type'-mapping (filter-mapping or servlet-mapping).
        for ( final Element element : elements )
        {
            final String name = element.elementTextTrim( type + "-name" );
            if ( typeName.equals( name ) )
            {
                final List<Element> urlPatternElements = element.elements( "url-pattern" );
                for ( final Element urlPatternElement : urlPatternElements )
                {
                    final String urlPattern = urlPatternElement.getTextTrim();
                    if ( urlPattern != null )
                    {
                        result.add( urlPattern );
                    }
                }

                // A filter can also be mapped to a servlet (by name). In that case, all url-patterns of the corresponding servlet-mapping should be used.
                if ( "filter".equals( type ) )
                {
                    final List<Element> servletNameElements = element.elements( "servlet-name" );
                    for ( final Element servletNameElement : servletNameElements )
                    {
                        final String servletName = servletNameElement.getTextTrim();
                        if ( servletName != null )
                        {
                            result.addAll( getUrlPatterns( "servlet", webXml, servletName ) );
                        }
                    }
                }
                break;
            }
        }

        Log.debug("Found {} URL pattern(s) for {} '{}': {}", result.size(), type, typeName, String.join(",", result));
        return result;
    }
Retrieves all URL patterns that apply to a specific filter.

@param webXml web.xml document, parsed as XML (cannot be null)
@param filterName The name of the filter (cannot be null or empty).
@return A collection (possibly empty, but never null).
xmppserver/src/main/java/org/jivesoftware/util/WebXmlUtils.java