title: how to use jquery autocomplete?
body: <p>i am creating a web project using JSP, and is trying to implement a simple search for users from my database using jquery autocomplete, however i am having trouble understanding how it works. i have little to no knowledge on jquery and ajax just to let you know. i have done the following code and am stuck.</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8" import="ewa.dbConnect,ewa.sendEmail,ewa.pwGen,ewa.hashPw,java.sql.*" %&gt;
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
     "http://www.w3.org/TR/html4/loose.dtd"&gt;
  
  &lt;html&gt;
      &lt;head&gt;
          &lt;link rel="stylesheet" type="text/css" href="css/jquery.autocomplete.css" /&gt;
          &lt;script src="js/jquery.autocomplete.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript"
              src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.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;input type="text" id="search" name="search"/&gt;
          &lt;script&gt;
          $("#search").autocomplete("getdata.jsp");
      &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>getdata.jsp</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8" import="ewa.dbConnect,java.sql.*" %&gt;
  &lt;%! dbConnect db = new dbConnect(); %&gt;
  &lt;%
  String query = request.getParameter("q");
  db.connect();
  Statement stmt = db.getConnection().createStatement();
  ResultSet rs = stmt.executeQuery("SELECT username FROM created_accounts WHERE username LIKE "+query);
  while(rs.next())
  {
      out.println(rs.getString("username"));
  }
  db.disconnect
  %&gt;
  </code></pre>
  
  <p>if i am not wrong i read from a website, the parameter q is default and is just there, however how do i display the data? how do i pass the values from getdata.jsp into the autocomplete?</p>