private void initializeWebServer(final Builder b) throws IOException {
    // Set handling for low resource conditions.
    final LowResourceMonitor low = new LowResourceMonitor(webServer);
    low.setLowResourcesIdleTimeout(10000);
    webServer.addBean(low);

    // Configure the global context handler
    portHandlerWrapper = new PortHandlerWrapper();
    webServer.setHandler(portHandlerWrapper);

    if (b.usePAM) {
      setupPam(b, portHandlerWrapper);
    }

    // Configures the web server connector and port handler to listen on
    // Also creates and adds the web application context to the server to which the servlets will be added
    ContextHandlerCollection portHandler = createAndAddWebApp(b);

    addServlet("jmx", "/jmx", JMXJsonServlet.class);
    addServlet("conf", "/conf", ConfServlet.class);
    addServlet("stacks", "/stacks", StackServlet.class);
    addServlet("conflog", "/conflog", Log4j2ConfiguratorServlet.class);

    final String asyncProfilerHome = ProfileServlet.getAsyncProfilerHome();
    if (asyncProfilerHome != null && !asyncProfilerHome.trim().isEmpty()) {
      addServlet("prof", "/prof", ProfileServlet.class);
      Path tmpDir = Paths.get(ProfileServlet.OUTPUT_DIR);
      if (Files.notExists(tmpDir)) {
        Files.createDirectories(tmpDir);
      }
      ServletContextHandler genCtx = new ServletContextHandler(portHandler, "/prof-output");
      setContextAttributes(genCtx.getServletContext(), b.contextAttrs);
      genCtx.addServlet(ProfileOutputServlet.class, "/*");
      genCtx.setResourceBase(tmpDir.toAbsolutePath().toString());
      genCtx.setDisplayName("prof-output");
    } else {
      LOG.info("ASYNC_PROFILER_HOME env or -Dasync.profiler.home not specified. Disabling /prof endpoint..");
    }
    ServletContextHandler staticCtx = new ServletContextHandler(portHandler, "/static");
    staticCtx.setResourceBase(getWebAppsPath(b.name) + "/static");
    staticCtx.addServlet(DefaultServlet.class, "/*");
    staticCtx.setDisplayName("static");
    disableDirectoryListingOnServlet(staticCtx);

    String logDir = getLogDir(b.conf);
    if (logDir != null) {
      ServletContextHandler logCtx = new ServletContextHandler(portHandler, "/logs");
      setContextAttributes(logCtx.getServletContext(), b.contextAttrs);
      if(b.useSPNEGO) {
        setupSpnegoFilter(b,logCtx);
      }
      logCtx.addServlet(AdminAuthorizedServlet.class, "/*");
      logCtx.setResourceBase(logDir);
      logCtx.setDisplayName("logs");
    }

    // Define the global filers for each servlet context except the staticCtx(css style).
    Optional<Handler[]> handlers = Optional.ofNullable(portHandler.getHandlers());
    handlers.ifPresent(hs -> Arrays.stream(hs)
        .filter(h -> h instanceof ServletContextHandler && !"static".equals(((ServletContextHandler) h).getDisplayName()))
        .forEach(h -> b.globalFilters.forEach((k, v) ->
            addFilter(k, v.getKey(), v.getValue(), ((ServletContextHandler) h).getServletHandler()))));
  }
Set servlet context attributes that can be used in jsp.
common/src/java/org/apache/hive/http/HttpServer.java