code: static void sendResponse(String output, HttpServletResponse response)
        throws IOException {
      PrintWriter out = null;
      try {
        out = response.getWriter();
        out.write(output);
      } finally {
        if (out != null) {
          out.close();
        }
      }
    }
docs: Send string output when serving http request.
  @param output data to be sent
  @param response http response
  @throws IOException