private static Map<String, String> getInitParams( String type, Document webXml, String typeName )
    {
        Log.trace("Looking for init params for {} '{}'", type, typeName);
        final Map<String, String> result = new HashMap<>();
        final List<Element> elements = webXml.getRootElement().elements( type ); // all elements of 'type' (filter or servlet).
        for ( final Element element : elements )
        {
            final String name = element.elementTextTrim( type + "-name" );
            if ( typeName.equals( name ) )
            {
                final List<Element> initParamElements = element.elements( "init-param" );
                for ( final Element initParamElement : initParamElements )
                {
                    final String pName  = initParamElement.elementTextTrim( "param-name" );
                    final String pValue = initParamElement.elementTextTrim( "param-value" );
                    if ( pName == null || pName.isEmpty() ) {
                        Log.warn( "Unable to add init-param that has no name" );
                    }
                    else
                    {
                        result.put( pName, pValue );
                    }
                }
            }
        }

        Log.debug("Found {} init-params(s) for {} '{}'", result.size(), type, typeName);
        return result;
    }
Retrieves a map of init param/values for a particular filter from a web.xml document.

For filter 'message' of this web.xml document, returns a map with two entries: foo-&gt; bar, test-&gt;value.
&lt;filter&gt;
  &lt;filter-name&gt;message&lt;/filter-name&gt;
  &lt;filter-class&gt;com.acme.filter.MessageFilter&lt;/filter-class&gt;
  &lt;init-param&gt;
    &lt;param-name&gt;foo&lt;/param-name&gt;
    &lt;param-value&gt;bar&lt;/param-value&gt;
  &lt;/init-param&gt;
  &lt;init-param&gt;
    &lt;param-name&gt;test&lt;/param-name&gt;
    &lt;param-value&gt;value&lt;/param-value&gt;
  &lt;/init-param&gt;
&lt;/filter&gt;

Parameters with no or empty name are ignored. When multiple parameters have the same name, only one of them is
returned.

@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 map (possibly empty, but never null).
xmppserver/src/main/java/org/jivesoftware/util/WebXmlUtils.java