title: Java JSONArrray iterate in Javascript providing 'undefined' result
body: <p>I want to iterate the JSONArray in my Java servlet into a JSP page using javascript. 
  This is my java codes in servlet,</p>
  
  <pre><code>JSONArray array = new JSONArray();
  for (int t = 1; t &lt; row; t++) {
                      JSONObject object = new JSONObject();
                      object.put("oid", "ghf");
                      object.put("cid", "fgh");
                      object.put("oid", "hf");
                      object.put("cid", "fir");
                      array.add(object);
  </code></pre>
  
  <p>in JSP,the </p>
  
  <pre><code>            var obj = '&lt;%=array%&gt;';
              var myJSON = JSON.stringify(obj);
              alert("myJSON = " + myJSON);
              for (var i = 0; i &lt; myJSON.length; i++) {
                  document.write('&lt;h4&gt;' + myJSON[i].cid + '&lt;/h4&gt;');
              }
  </code></pre>
  
  <p>Thankyou for helping.</p>
  
  <p>The output is  </p>
  
  <blockquote>
    <p>undefined</p>
  </blockquote>