benim servlet'dir aşağıdaki kodu vardır:Ui'deki json nesne çıktısı nasıl görüntülenir?
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&pretty=1&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);
}
Bir uyarı kutusunda kullanıcı arayüzüne bir json nesnesi veya arraylist olarak jsonstring1 geçmek ve kullanıcı arayüzünde görüntülemek istediğinizi? Lütfen bunu nasıl yapacağınıza dair öneriniz? Teşekkürler.