hgc-ghc
Good Good Study!!! Day Day Up!!!
posts - 40,comments - 3,trackbacks - 0
//servlet
package com.shxt.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 CheckCreateMaServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String identity = request.getParameter("vc") != null ? request.getParameter("vc") : "" ;
//System.out.println(identity);
        String realidentity=(String)request.getSession().getAttribute("rand");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html");
        if(!identity.trim().equalsIgnoreCase(realidentity.trim())){
       response.getWriter().write("no");//验证码不对
       response.getWriter().close();
        }else{
        request.getSession().removeAttribute("rand");
        response.getWriter().write("yes");//正确的验证码 
       response.getWriter().close();
        }
}
}
posted on 2012-08-29 12:03 宏才 阅读(246) 评论(0)  编辑  收藏 所属分类: ajax