package com.cybookstore.struts.action;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.cybookstore.db.dao.User;
import com.cybookstore.db.dao.UserCart;
import com.cybookstore.db.dao.UserDAO1;
import com.cybookstore.db.dao.UserInfo;
import com.cybookstore.db.dao.UserLoginDAO;
import com.cybookstore.db.dao.UserManager;
import com.cybookstore.db.dao1.Userinfo;
/**
* MyEclipse Struts
* Creation date: 01-05-2008
*
* XDoclet definition:
* @struts.action validate="true"
* @struts.action-forward name="successfully" path="/suc.jsp"
* @struts.action-forward name="failure" path="/fail.jsp"
*/
public class LoginAction1 extends Action {
private static final Logger log = Logger.getLogger(LoginAction1.class);
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String name=request.getParameter("textfield");
String password=request.getParameter("textfield2");
try {
String temp=new String(name.getBytes("ISO-8859-1"),"gb2312");
log.info("user: "+temp+" : "+password);
Userinfo user=new Userinfo(temp,"","","","","","");
Userinfo user2= UserDAO1.Login(user);
// UserLogin.Login(name,password);
UserInfo user1= UserManager.getUser(1);
// ArrayList ss=user1.getUserlist();
HttpSession session=request.getSession();
session.setAttribute("user", user1);
if(password!=null&&user2!=null&&!password.equals("")&&password.equals(user2.getPassword())){
UserCart c=new UserCart();
session.setAttribute("cart", c);
System.out.println(user);
return mapping.findForward("successful");
}else {
return mapping.findForward("failure");
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return mapping.findForward("failure");
}
}
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.cybookstore.db.dao.User;
import com.cybookstore.db.dao.UserCart;
import com.cybookstore.db.dao.UserDAO1;
import com.cybookstore.db.dao.UserInfo;
import com.cybookstore.db.dao.UserLoginDAO;
import com.cybookstore.db.dao.UserManager;
import com.cybookstore.db.dao1.Userinfo;
/**
* MyEclipse Struts
* Creation date: 01-05-2008
*
* XDoclet definition:
* @struts.action validate="true"
* @struts.action-forward name="successfully" path="/suc.jsp"
* @struts.action-forward name="failure" path="/fail.jsp"
*/
public class LoginAction1 extends Action {
private static final Logger log = Logger.getLogger(LoginAction1.class);
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String name=request.getParameter("textfield");
String password=request.getParameter("textfield2");
try {
String temp=new String(name.getBytes("ISO-8859-1"),"gb2312");
log.info("user: "+temp+" : "+password);
Userinfo user=new Userinfo(temp,"","","","","","");
Userinfo user2= UserDAO1.Login(user);
// UserLogin.Login(name,password);
UserInfo user1= UserManager.getUser(1);
// ArrayList ss=user1.getUserlist();
HttpSession session=request.getSession();
session.setAttribute("user", user1);
if(password!=null&&user2!=null&&!password.equals("")&&password.equals(user2.getPassword())){
UserCart c=new UserCart();
session.setAttribute("cart", c);
System.out.println(user);
return mapping.findForward("successful");
}else {
return mapping.findForward("failure");
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return mapping.findForward("failure");
}
}