www.pudn.com > bookshop.zip > CheckUserServlet.java, change:2013-07-07,size:917b


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 com.tarena.bean.User; 
import com.tarena.dao.UserDao; 
 
public class CheckUserServlet extends HttpServlet { 
 
 
	public void service(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException { 
 
		    request.setCharacterEncoding("utf-8"); 
		    response.setContentType("text/html;charset=utf-8"); 
		    String email = request.getParameter("email"); 
		     
		    UserDao dao = new UserDao(); 
		    User user = dao.getUserByEmail(email); 
		     
		    PrintWriter out = response.getWriter(); 
		    if(user ==null){ 
		    	out.write("0"); 
		    }else{ 
		    	out.write("1"); 
		    } 
	} 
 
}