title: Passing a large JSON object from JSP to JavaScript
body: <p>I know the question of passing Json from servlet/Jsp to javascript has been asked a lot, but my Json object is huge and contains around 400 records.
  I have tried passing it from jsp to javascript as follows:</p>
  
  <p><code>var json = ${json};</code></p>
  
  <p>but the json object breakes and doesn't finish till the last record. When i print the json object in the servlet it has no breaks. I basically have a servlet which generates a JSON result and passes it to a JSP file and i want the result to be used to plot poly-lines and points on google map. There is no request being  sent form the jsp to my servlet. 
  I am really a novice coder.</p>
  
  <p>I use RequestDispatcher to send the data to jsp as follows:</p>
  
  <pre><code>request.setAttribute("json", json1);
  RequestDispatcher dispatcher = request.getRequestDispatcher("result.jsp");
  dispatcher.forward(request, response);
  </code></pre>
  
  <p>While execution the HTML page is not completely generated:
  <a href="http://i.stack.imgur.com/1ED5f.png" rel="nofollow">HTML-break</a></p>
  
  <p>The jsp code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-  8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;script src="http://maps.googleapis.com/maps/api/js"&gt;
  &lt;/script&gt;
  &lt;%
  JSONObject json = (JSONObject)request.getAttribute("json");
  %&gt;
  &lt;script&gt;
  var json = ${json};
  function initialize() {
  //Set of statements
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="googleMap" style="width:1000px;height:1000px;"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The problem is in the statement <code>var json = ${json};</code></p>