package Javas;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import ku.UserInfoPO;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
public class Find extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Configer config=new Configer();
Session session=config.getSession();
Transaction transaction=session.beginTransaction();
String hqlsql="from UserInfoPO as user where user.userName=?";
Query query=session.createQuery(hqlsql);
query.setParameter(0,request.getParameter("username"));
List list=query.list();
transaction.commit();
session.close();
if(list.size()!=0){
String password= request.getParameter("password");
UserInfoPO ui=new UserInfoPO();
for(int i=0;i<list.size();i++){
ui=(UserInfoPO)list.get(i);
if(ui.getPassword().equals(password)){
response.sendRedirect("../success.jsp?value=7");
return ;
}
}
response.sendRedirect("../success.jsp?value=2");
}else{
response.sendRedirect("../success.jsp?value=1");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
}
}
评论0
最新资源