title: Ajax jquery with JsonArray in JSP
body: <p>I'm using <a href="http://www.json.org/javadoc/org/json/JSONArray.html" rel="nofollow">JSon-RPC library</a>.</p>
  
  <p><strong>Servlet:</strong></p>
  
  <p>I want to put <code>List&lt;Student&gt;</code> into <code>JSonArray</code> that is the same as <code>{["name":"AAA","age":"24"]["name":"BBB","age":"12"]}</code>.
  <code>JsonArray</code> have a contructor that accepts a <code>Collection</code> being the same as parameter.
  If result is a <code>JsonObject</code> then I'll response to client with method <code>out.print(instanceJsonObject.toString())</code>.
  Now I don't know how to response <code>JsonArray</code> from Server to Client.</p>
  
  <pre><code>ArrayList&lt;Student&gt; list = new ArrayList&lt;Student&gt;();
  list.add(new Student("Vu Duc Hoan", "C1010G", "24"));
  list.add(new Student("Vu Duc Hoan2", "C1010G2", "242"));
  
  JSONObject js = new JSONObject();
  org.json.JSONArray array = new JSONArray(list);
  </code></pre>
  
  <p><strong>Client:</strong></p>
  
  <p>Can you tell me how to get data in JsonArray? I'm using <code>$.getJson</code></p>
  
  <pre><code>btnJson.click(function(){
      $.getJSON("../DemoAjax/Controller?action=getJson",function(data){
  });
  </code></pre>