I am newbie. I am sending the data from struts action using httpservlet response. What should i do to retrieve this value in javascript to set these values to an html element.
Used Struts action and httpservlet object to write to the response.
Gson gson = new Gson(); //using gson-2.3.1.jar
//log.debug("Printing values ... ");
//log.debug(gson.toJson( languagesResponse.getLanguages()));
response.setContentType("application/json");
// Get the printwriter object from response to write the required json object to the output stream
PrintWriter out = response.getWriter();
// Assuming your json object is **jsonObject**, perform the following, it will return your json object
out.print(gson.toJson( languagesResponse.getLanguages()));
out.flush();
Let the json return the value as :
[{"stringCode":"default","numberCode":0,"__hashCodeCalc":false},{"stringCode":"en_US","numberCode":1,"__hashCodeCalc":false}]
I want to get this value for javascript elemtent.