@Override
  public void doGet(HttpServletRequest request, HttpServletResponse response) {
    try {
      if (!HttpServer.isInstrumentationAccessAllowed(getServletContext(), request, response)) {
        return;
      }
      JsonGenerator jg = null;
      PrintWriter writer = null;
      try {
        writer = response.getWriter();

        response.setContentType("application/json; charset=utf8");
        response.setHeader(ACCESS_CONTROL_ALLOW_METHODS, "GET");
        response.setHeader(ACCESS_CONTROL_ALLOW_ORIGIN, "*");

        jg = jsonFactory.createJsonGenerator(writer);
        jg.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
        jg.useDefaultPrettyPrinter();
        jg.writeStartObject();

        // query per mbean attribute
        String getmethod = request.getParameter("get");
        if (getmethod != null) {
          String[] splitStrings = getmethod.split("\\:\\:");
          if (splitStrings.length != 2) {
            jg.writeStringField("result", "ERROR");
            jg.writeStringField("message", "query format is not as expected.");
            jg.flush();
            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
            return;
          }
          listBeans(jg, new ObjectName(splitStrings[0]), splitStrings[1],
              response);
          return;
        }

        // query per mbean
        String qry = request.getParameter("qry");
        if (qry == null) {
          qry = "*:*";
        }
        listBeans(jg, new ObjectName(qry), null, response);
      } finally {
        if (jg != null) {
          jg.close();
        }
        if (writer != null) {
          writer.close();
        }
      }
    } catch (IOException e) {
      LOG.error("Caught an exception while processing JMX request", e);
      response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (MalformedObjectNameException e) {
      LOG.error("Caught an exception while processing JMX request", e);
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    }
  }
Process a GET request for the specified resource.

@param request
         The servlet request we are processing
@param response
         The servlet response we are creating
common/src/java/org/apache/hive/http/JMXJsonServlet.java