接收ajax传过来的数据
客户端代码:
服务器端代码:
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("textml;charset=utf-8");
PrintWriter out = response.getWriter();
String uname=request.getParameter("uname");
System.out.println(uname);
boolean uExists=false;
if(uname.equals("hdjr"))
{ uExists=true;
out.print(uExists);
}else{
out.print(uExists);
}
out.flush();
out.close();
}
/**
* The doPost method of the servlet.
*
* 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
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
}