title: Creating a json object in jsp and using it with JQuery
body: <p>I've created a JSP application, which gets results based on a user search (using lucene). I store the results in a Bean.</p>
  
  <p>I'm also using Jquery Ajax to display the results.</p>
  
  <pre><code>$.ajax({
      url : "search.jsp",
      data : "search=test",
      success : function(html) {
          ("#search_results").hide().html(html).fadeIn(1500);
      }
  });
  </code></pre>
  
  <p>search.jsp</p>
  
  <pre><code>for (int i = 0; i &lt; size; i++) {
      out.println(searchResult.get(i).getHTML());
  }
  </code></pre>
  
  <p>This is working fine, however I want to change it so it returns a JSON object to JQuery and then let JQuery parse the objects and display the results</p>
  
  <p>I am not sure how to do this as I'm new to JSON objects and JSP.
  I could possibly do something like </p>
  
  <pre><code>JSONObject json = new JSONObject();
  json.put("title", "TITLE_TEST");
  json.put("link", "LINK_TEST");
  </code></pre>
  
  <p>but I dont know how to return <code>json</code> to jquery then let jquery parse the objects</p>
  
  <p>Any help is appreciated :)</p>