private Document mangleWebXml(final Document doc) {
    final Element docElement = doc.getDocumentElement();
    final NodeList nodelist = docElement.getChildNodes();
    Node firstFilter = null;
    Node displayElement = null;
    Node afterDisplayElement = null;

    for (int i = 0; i < nodelist.getLength(); i++) {
      final Node node = nodelist.item(i);
      final String name = node.getNodeName();
      if ("display-name".equals(name)) {
        displayElement = node;
      } else {
        if ("filter".equals(name)) {
          if (firstFilter == null) {
            firstFilter = node;
          }
        }
        if (displayElement != null && afterDisplayElement == null) {
          afterDisplayElement = node;
        }
      }
    }

    Node initParam;
    final Element filter = doc.createElement("filter");
    append(doc, filter, "filter-name", "gemfire-session-filter");
    append(doc, filter, "filter-class", GEMFIRE_FILTER_CLASS);

    // Set the type of cache
    initParam = append(doc, filter, "init-param", null);
    append(doc, initParam, "param-name", "cache-type");
    append(doc, initParam, "param-value", argValues.getFirstResult(ARG_CACHE_TYPE));


    if (argValues.isDefined(ARG_GEMFIRE_PARAMETERS)) {
      for (String[] val : argValues.getAllResults(ARG_GEMFIRE_PARAMETERS)) {
        String gfParam = val[0];
        int idx = gfParam.indexOf("=");
        initParam = append(doc, filter, "init-param", null);
        append(doc, initParam, "param-name", gfParam.substring(0, idx));
        append(doc, initParam, "param-value", gfParam.substring(idx + 1));
      }
    }

    Node first = firstFilter;
    if (first == null) {
      if (afterDisplayElement != null) {
        first = afterDisplayElement;
      }
    }
    if (first == null) {
      first = docElement.getFirstChild();
    }
    docElement.insertBefore(filter, first);
    final Element filterMapping = doc.createElement("filter-mapping");
    append(doc, filterMapping, "filter-name", "gemfire-session-filter");
    append(doc, filterMapping, "url-pattern", "/*");
    docElement.insertBefore(filterMapping, after(docElement, "filter"));
    return doc;
  }
The main entry point for processing

@throws Exception if any errors occur.
extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/Installer.java