package com.servlets;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class checkServlet extends HttpServlet {
/**
* 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
*/
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
// 从数据库中读取名字然后判断是否存在
// 这里简写成规定的几个名字
response.addHeader("pragma", "no-cache");
response.addHeader("cache-control", "no-cache");
response.addHeader("expires", "0");
String name = request.getParameter("name");
if (name.equals("zzx") || name.equals("aaa")) {
out.print("true");
} else {
out.print("false");
}
}
}
Ajax用例
需积分: 0 35 浏览量
2008-08-21
21:25:04
上传
评论
收藏 1.08MB RAR 举报
zhouzongxi
- 粉丝: 7
- 资源: 12
评论0