@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("{} is incomplete. Sending auto-refresh header..", requestedFile);
      resp.setHeader("Refresh", "2," + req.getRequestURI());
      resp.getWriter().write("This page will auto-refresh every 2 second until output file is ready..");
    } else {
      super.doGet(req, resp);
    }
  }
Servlet to serve files generated by {@link ProfileServlet}
common/src/java/org/apache/hive/http/ProfileOutputServlet.java