code: public void removeServlet(String name, String pathSpec,
        Class<? extends HttpServlet> clazz) {
      if(clazz == null) {
         return;
      }
  
      //remove the filters from filterPathMapping
      ServletHandler servletHandler = webAppContext.getServletHandler();
      List<FilterMapping> newFilterMappings = new ArrayList<FilterMapping>();
  
      //only add the filter whose pathSpec is not the to-be-removed servlet
      for(FilterMapping mapping: servletHandler.getFilterMappings()) {
        for(String mappingPathSpec: mapping.getPathSpecs()) {
          if(!mappingPathSpec.equals(pathSpec)){
            newFilterMappings.add(mapping);
          }
        }
      }
    
      servletHandler.setFilterMappings(newFilterMappings.toArray(new FilterMapping[newFilterMappings.size()]));
  
      removeInternalServlet(name, pathSpec, clazz);
    }
docs: Remove a servlet in the server.
  @param name The name of the servlet (can be passed as null)
  @param pathSpec The path spec for the servlet
  @param clazz The servlet class