Sending JSON data Servlet Applet communication example

前端 未结 1 1372
予麋鹿
予麋鹿 2021-01-26 07:09

Hi am developing an application in which servlet has to send data(coming from database) to applet i have fallowed this link

it is very useful but they mentioned passing

相关标签:
1条回答
  • 2021-01-26 07:44

    if you are going to create or read json strings, then I'd recommend using Google's Gson.

    To send a json response from the servlet do this:

    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
            PrintWriter writer = null;
            try {
                writer = response.getWriter();
                writer.write(json);
            } finally {
                writer.close();
            }
    
    0 讨论(0)
提交回复
热议问题