title: Autocomplete jQuery UI plugin with JSP and Servlets not working
body: <p>I'm trying to use jQuery UI autocomplete widget in my Java Webb App.</p>
  
  <p>As it is right now I have the following code:</p>
  
  <p><strong>View (buscarFoto.jsp)</strong></p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;link rel="stylesheet" type ="text/css" href="css/jquery-ui-1.10.3.custom.css"/&gt;
      &lt;script src="js/jquery-1.10.2.min.js"&gt;&lt;/script&gt;
      &lt;script src="js/jquery-ui-1.10.3.custom.js"&gt;&lt;/script&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;title&gt;JSP Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h3&gt;Escull usuari&lt;/h3&gt;
      &lt;input type="text" id="usuari" name="usuari"/&gt;
  
      &lt;script&gt;
          $("#usuari").autocomplete({
              source: "Controller?action=llistaUsuaris"
          });
      &lt;/script&gt;   
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>Controller (Controller.java (servlet))</strong> (DoPost and DoGet are overwritten, Controller.java works just fine as Servlet in any other part of the WebApp)</p>
  
  <pre><code>    response.setContentType("text/html;charset=UTF-8");
      PrintWriter out = response.getWriter();
  
      try {
  
          GestioDB_Postgres db = new GestioDB_Postgres();
          HttpSession session = request.getSession();
          String op = request.getParameter("action");
  
          if (op.equals("llistaUsuaris")) {
              String query = request.getParameter("term");
              List&lt;String&gt; usuaris = db.llistaUsuaris(query);
              Iterator&lt;String&gt; iterator = usuaris.iterator();
              while (iterator.hasNext()) {
                  String usuari = (String) iterator.next();
                  out.println(usuari);
              }
  
          }
  </code></pre>
  
  <p>The call to the database in line 3 of the Controller works just fine (I've tested it), and the controller itself works fine too (it prints the appropriate "usuaris" when I run it in NetBeans), the .jsp page sends the request as "term", but the autocomplete function simply doesn't do anything.</p>
  
  <p>I read in another question that someone suggested using JSON but I'd rather not use it if it can be avoided. Can anyone point me in the right direction?</p>
  
  <p>Thank you.</p>