I have one simple User Registration form. It includes name, age, sex & city. But here city is coming form city master table & displaying user as a combo box. But when i am trying to store full user registration information through my UserDAO, how can i access that current selected city value ? My User Registration jsp form contains :
<s:form action="UserAction" >
<s:textfield name="name" label="User Name" />
<s:textfield name="age" label="Age" />
<s:radio name="sex" label="Sex" list="{'M','F'}" />
<s:select list="cities" key="cities.name" listValue="name">
</s:select>
<s:submit />
</s:form>
Now i am calling UserAction's execute() method. It contains :
public String execute() throws Exception {
UserDAO.insert(user);
return SUCCESS;
}
My DAO's insert method has following code :
public static void insert(UserBean daoUb) throws Exception {
Connection daoConn = null;
CityBean cb=new CityBean();
cb=daoUb.getCity();
System.out.println("cb = "+cb);
daoConn = connectionUtil.getConnection();
Statement daoSt = daoConn.createStatement();
String str = "INSERT user (name,age,sex,city) VALUES('" + daoUb.getName() + "'," + daoUb.getAge() + ",'" + daoUb.getSex() + "','"+cb.getName()+"')";
daoSt.executeUpdate(str);
//daoConn.close();
}
Plz suggest me, if anyone have any suggestion. I am stuck with this problem....