www.pudn.com > bookshop.zip > CheckCode.java, change:2013-07-08,size:938b


package com.tarena.web; 
 
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; 
import javax.servlet.http.HttpSession; 
 
public class CheckCode extends HttpServlet { 
 
	public void service(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException { 
            request.setCharacterEncoding("utf-8"); 
            response.setContentType("text/html;charset=utf-8"); 
            String code = request.getParameter("code"); 
		    HttpSession session = request.getSession(); 
		    String number = (String)session.getAttribute("number"); 
		    PrintWriter out = response.getWriter(); 
		    if(code.equals(number)){ 
		    	out.write("1"); 
		    }else{ 
		    	out.write("0"); 
		    } 
		     
		     
	} 
 
}