title: How make a servlet print in html?
body: <p>I have an jsp page, <em>index</em>, this is it's code:</p>
  
  <pre><code>&lt;script src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt;
  &lt;script src="alteraSala.js"&gt;&lt;/script&gt;
  &lt;div id="conteudo"&gt;
      &lt;select id="sala"&gt;
          ...
      &lt;/select&gt;
      &lt;div id="resultado"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My servlet is something like:</p>
  
  <pre><code>import java.io.IOException;
  import java.io.PrintWriter;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  @WebServlet("/hello")
  public class Hello extends HttpServlet {
      @Override
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
  
          response.setContentType("text/plain");
          response.setCharacterEncoding("UTF-8");
  
          PrintWriter out = response.getWriter();  
          out.println("&lt;b&gt;HELLO&lt;/b&gt;");
      }
  }
  </code></pre>
  
  <p>I've also got an AJAX file:</p>
  
  <pre><code>$(document).ready(function () {
      $('#sala').change(function (event) {
          var name = $('#sala').val();
          $.get('../EditarSala', {
              sala: name
          }, function (responseText) {
              $('#resultado').text(responseText);
          });
      });
  });
  </code></pre>
  
  <p>The problem is that the output of the page is not:
  <strong>HELLO</strong>
  It's:
  &lt;b>HELLO&lt;/b></p>
  
  <h1>Edit:</h1>
  
  <p>Changed:</p>
  
  <pre><code>response.setContentType("text/plain");
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>response.setContentType("text/html");
  </code></pre>
  
  <p>Still isn't working</p>
  
  <h1>Edit 2:</h1>
  
  <p>For some reason when I change the AJAX file from:</p>
  
  <pre><code>$('#resultado').text(responseText);
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>$('#resultado').append(responseText);
  </code></pre>
  
  <p>It displays the text properly, but I can't use append.</p>