I have an Ajax call in my JSP which returns a JSON object in the form of Java string.
public void doGet(HttpServletRequest request, HttpServletResponse res) throws IOException, ServletException {
try {
String fromDate = request.getParameter("drFrom");
String toDate = request.getParameter("drTo");
JSONArray jsonArray = chartData.getCCSBJson(fromDate, toDate);
res.setContentType("application/json");
res.getWriter().write(jsonArray.toString());
Can I send the JSON to JSP without using jsonArray.toString() inside res.getWriter().write(jsonArray.toString());, because I am not able to parse the JSON in JSP after sending it as a string.
This is related to the post: How to parse a JSON object from ajax call in Java Script
JSONXxxobject to String because that's the real JSON format. The problem is in yourJSONArray. Post the code forchartData.getCCSBJson(fromDate, toDate). Or maybe the problem is in JSP side. Post how you're parsing the String in your client.