Originally Posted by
arvindbis
then you should create an object of bean as
Logic_Build contact =(Logic_Build)form;
not as
please mention where you accessed your database here??
Hi arvindbis
Thank you for your help.
I have a table (
b_users) and for storing the values from DB i have
Logic_Build bean class
for retrieving form values i have
LoginForm which is Form bean class. in my table i stored 4 rows with user_name and password. now i need to compare the form values with my DB values. but my code is checking only with first row. please help me to compare with all rows of DB
my code is..
/**
* Program for comparing DB values with form values for login
*/
public class LoginAction extends org.apache.struts.action.Action {
private final static String SUCCESS = "success";
private final static String FAILURE = "failure";
HttpSession session=null;
/* ++++++++++++execute method of ActionForward ++++++++++ */
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
/* ++++++++++++ DB logic +++++++++++++++ */
Reader reader=Resources.getResourceAsReader("Xml/SqlMapConfig.xml");
SqlMapClient sqlMap=SqlMapClientBuilder.buildSqlMapClient(reade r);
ArrayList lst=(ArrayList)sqlMap.queryForList("getAll",null);
Iterator itr=lst.iterator();
while(itr.hasNext())
{
Logic_Build contact =(Logic_Build)itr.next();
LoginForm loginForm = (LoginForm) form;
if ((loginForm.getUser_name().equals(contact.getUser_ name()))&& (loginForm.getPassword().equals(contact.getPasswor d())))
{
return mapping.findForward(SUCCESS);
}
else {
return mapping.findForward(FAILURE);
}
}//while
return mapping.findForward(SUCCESS);
}//execute
}
thanks in advance