@Override
  protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
    throws ServletException, IOException {
    String absoluteDiskPath = getServletContext().getRealPath(req.getPathInfo());
    File requestedFile = new File(absoluteDiskPath);
    // async-profiler version 1.4 writes 'Started [cpu] profiling' to output file when profiler is
    // running which gets replaced by final output. If final output is not ready yet, the file size
    // will be <100 bytes (in all modes).
    if (requestedFile.length() < 100) {
      LOG.info(requestedFile + " is incomplete. Sending auto-refresh header.");
      String refreshUrl = req.getRequestURI();
      // Rebuild the query string (if we have one)
      if (req.getQueryString() != null) {
        refreshUrl += "?" + sanitize(req.getQueryString());
      }
      ProfileServlet.setResponseHeader(resp);
      resp.setHeader("Refresh", REFRESH_PERIOD + ";" + refreshUrl);
      resp.getWriter().write("This page will be auto-refreshed every " + REFRESH_PERIOD
        + " seconds until the output file is ready. Redirecting to " + refreshUrl);
    } else {
      super.doGet(req, resp);
    }
  }
Servlet to serve files generated by {@link ProfileServlet}
hbase-http/src/main/java/org/apache/hadoop/hbase/http/ProfileOutputServlet.java