title: Getting response from struts 1 method using json,jquery and jsp
body: <p>I am using Struts 1, JSP, JSON and jQuery in my project. Now I am sending JavaScript array using JSON to action method  and unable to return response from struts action method back to JSP page. Does anybody have a working example or suggestion?</p>
  
  <p><strong>JavaScript code</strong></p>
  
  <pre><code>console.log("start calculateDifference");
  console.log("route 1 lenght:"+newRoute1.length);
  console.log("route 2 lenght:"+newRoute2.length);
  var article = new Object();
  
  article.routeFirst = newRoute1;
  article.routeSecond = newRoute2;
  
  
  $.ajax({
      type: 'POST',
      url: '../../admin/cabsharing/findIntersesctionPoint.do',
      data : "point="+JSON.stringify(article),
      dataType: 'json',
  
  
      success: function(result) {
          console.log("success:"+result);
      },
      error: function(e){
          console.log("error:"+e);
      }
  
  });
  </code></pre>
  
  <p><strong>Java code</strong></p>
  
  <pre><code>Route route = new Route();
  route.setX(fmt.format(Double.parseDouble(f.getX())));
  route.setY(fmt.format(Double.parseDouble(f.getY())));
  
  
  String jsonString = gson.toJson(route);
  
  PrintWriter writer = response.getWriter();
  writer.print(jsonString);
  writer.flush();
  response.setContentType("application/json");
  
  return null;
  </code></pre>