title: Parsing JSON data from JSP
body: <p>i have a jsp on a server that returns me a JSON like this: {"link":"LINK_TEST","title":"TITLE_TEST"}</p>
  
  <p>I am trying to get this data from a client html page but i can do it.</p>
  
  <p>this is the jsp code: </p>
  
  <pre><code>&lt;%@page contentType="text/html; charset=UTF-8"%&gt;
  &lt;%@page import="org.json.simple.JSONObject"%&gt;
  &lt;%
      JSONObject json = new JSONObject();
      json.put("title", "TITLE_TEST");
      json.put("link", "LINK_TEST");
      out.print(json);
      out.flush();
  %&gt;
  </code></pre>
  
  <p>The jsp looks like this: {"link":"LINK_TEST","title":"TITLE_TEST"}</p>
  
  <p>And this is the client side code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
      &lt;html&gt;
      &lt;head&gt;        
      &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script&gt;
              $.ajax({
                  url : 'http://my_ip:my_port/json.jsp',
                  data : { search: 'test' },
                  dataType: 'json',
                  success : function(json) {
  
                  var ob = jQuery.parseJSON(json);
                  alert(ob.link+" "+ob.title);
  
                  document.getElementById("uno").innerHTML = ob.link;
                  document.getElementById("dos").innerHTML = ob.title;
                  }
  
              });
      &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
      &lt;h1 id="uno"&gt;&lt;/h1&gt;
      &lt;h1 id="dos"&gt;&lt;/h1&gt;
  
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>