title: How to write a Controller variable value back to the HTML page that sent the Ajax request without a page refresh?
body: <p>The following JavaScript</p>
  
  <pre><code>new Ajax.Request('/orders/check_first_last/A15Z2W2', 
  {asynchronous:true, evalScripts:true, 
  parameters:{first:$('input_initial').value, 
  last:$('input_final').value, 
  order_quantity:$('input_quantity').value}});
  </code></pre>
  
  <p>triggers an Ajax call to the <code>checkFirstLast</code> method in the <code>OrderController</code>:</p>
  
  <pre><code>@Controller
  @RequestMapping("/orders")
  public OrderController {
  
     @RequestMapping("/check_first_last/{code}")
     @ResponseBody
     public String checkFirstLast(@PathVariable String code, 
          @RequestParam int first, 
          @RequestParam int last, 
          @RequestParam("order_quantity") int orderQuantity)  {
         Integer newResult = new Integer(last - first);
         return newResult.toString();
    }
  }
  </code></pre>
  
  <p>If I want to write the <code>newResult</code> String from the <code>checkFirstLast</code> method into the <code>result_text</code> HTML element on the page that sends the Ajax request, replacing the value set by the <code>initialResult</code> JSTL variable:</p>
  
  <pre><code>&lt;h2 id="result_text"&gt;&lt;c:out value="${initialResult}"/&gt;&lt;/h2&gt;
  </code></pre>
  
  <p>what change would I need to make to the controller method above (<code>checkFirstLast</code>), now that I have already included the Jackson JSON library in my project?</p>