package com.lq.servlet;
import java.io.IOException;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.lq.utils.JdbcUtil;
publicclassAjaxServletextendsHttpServlet {/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/publicvoiddoGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/publicvoiddoPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String ser= request.getParameter("ser");
System.out.println(ser);
JdbcUtil ju=new JdbcUtil();
String sql="select name,card from t_users t where name like '%"+ser+"%'";
System.out.println(sql);
//List list=new ArrayList();
String s="";
try {
ResultSet rs=ju.querry(sql, null);
while(rs.next()){
System.out.println(rs.getString(1)+"_"+rs.getString(2)+",");
s=s+(rs.getString(1)+"_"+rs.getString(2)+",");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
response.getWriter().print(s);
}
}