title: How to return response to AJAX using jsp?
body: <p>I'm new to jsp, so I'd like to know how to return a response to AJAX.
  This is the code to submit the form using dojo with AJAX:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          dojo.require("dojo.io.iframe");
  
          dojo.addOnLoad(function() {
              upload = function(  ) {
              dojo.io.iframe.send({
                  form : "fileUploader",
                  handleAs : "html", //response type from the server
                  url : "url to jsp",//just example, not the real url
                  load : function(response, ioArgs) {
                      console.log(response, ioArgs);
                      return response;
                  },
                  error : function(response, ioArgs) {
                      console.log("error");
                      console.log(response, ioArgs);
                      return response;
                  }
              });
          };
          });
  </code></pre>
  
  <p></p>
  
  <p>and this is the fragment of the jsp code to return the response:</p>
  
  <pre><code>r = "&lt;p &gt;You have successfully uploaded your video. &lt;/p&gt;";
  response.setContentType("text/html");
  response.getWriter().write(r);
  </code></pre>
  
  <p>if I just use System.out.println(r), it does print the result in console, so the form is being submitted. So I think the problem is the way I'm returning the response or the way I'm handling it with dojo. </p>
  
  <p>Thanks in advance!</p>