title: How to display the json object output in the ui?
body: <p>I have the following code in my servlet:</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
      String line;
      StringBuffer jsonString = new StringBuffer();
      String starttime = "2010-01-16T12:07:48";
      String endtime = "2010-02-16T12:18:13";
  
      try {
  
          URL url = new URL("http://localhost:9200/indexname/_search?filter_path=hits.hits._source&amp;pretty=1&amp;size=10000000");
  
          String payload = "{\"query\":{\"filtered\":{\"filter\":{\"range\":{\"Date\":{\"lte\":\""+endtime+"\",\"gte\":\""+starttime+"\"}}}}},\"_source\":{\"include\":[\"ID\",\"Name\",\"Status\",\"Date\"]}}";
  
          HttpURLConnection connection1 = (HttpURLConnection) url.openConnection();
  
          connection1.setDoInput(true);
          connection1.setDoOutput(true);
          connection1.setRequestMethod("POST");
          connection1.setRequestProperty("Accept", "application/json");
          connection1.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
          OutputStreamWriter writer1 = new OutputStreamWriter(connection1.getOutputStream(), "UTF-8");
          writer1.write(payload1);
          writer1.close();
  
          BufferedReader br1 = new BufferedReader(new InputStreamReader(connection1.getInputStream()));
          while ((line = br1.readLine()) != null) {
               jsonString1.append(line);
          }
  
          br1.close();
          connection1.disconnect();               
  
      } catch (Exception e) {
          throw new RuntimeException(e.getMessage());
      }
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      out.print(jsonString);
      out.flush();
      out.close();
      RequestDispatcher dispatcher = request.getRequestDispatcher("index.jsp");
      dispatcher.forward(request, response);
  }
  </code></pre>
  
  <p>I want to pass the jsonstring1 as a json object or arraylist to the UI and display it in the UI in an alert box? Please advice on how to do this? Thanks.</p>