code: @Override
      protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
          Map<String,String> responseHeaders =
                  requestHandler.handleCorsPreflightRequest(
                          getOriginOrReferer(req),
                          req.getHeader("Access-Control-Request-Headers"));
          for (Map.Entry<String,String> entry : responseHeaders.entrySet()) {
              resp.setHeader(entry.getKey(),entry.getValue());
          }
      }
docs: OPTION requests are treated as CORS preflight requests
  
  @param req the original request
  @param resp the response the answer are written to