title: (AJAX - Jsp include) How to include a JSP with Ajax?
body: <p>I was trying to include a jsp page into an other page by an Ajax call.
  The problem is that if the page to be included has some white spaces between html elements, it will make the inlusion to fail.</p>
  
  <p>For example here is my  demo index.jsp: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function include() {
    alert("Hello from include function.");
  
    $.ajax({
      type: "GET",
      url: "Include",
      success: function() {
        alert("Ajax success function.");
        $("#container").html("&lt;jsp:include page='hello.jsp' /&gt;");
        alert("Ajax end success function.");
      }
    });
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;body&gt;
    &lt;button onclick="include()"&gt;Include&lt;/button&gt;
    &lt;div id="container" style="border: 1px solid red;"&gt;&lt;/div&gt;
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here is the hello.jsp page to be included (no spaces between elements tags or the include will fail): </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p&gt;Hello from the included file.&lt;/p&gt;&lt;p&gt;Hello from the included file.&lt;/p&gt;&lt;p&gt;Hello from the included file.&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>And the servlet has just a do-nothing (for now) doGet method.</p>
  
  <p>Does it appens the same to all of you? Is there something wrong with my code?
  Is there an other working way of making the same task?</p>