
Now it’s time to add a new user to the database. Let’s write an action first that can save a user in the database. Create a new Action class ‘AddUserAction’ and add the following code in its execute method.
User user = (User) form;
try{
UserManager.getInstance().saveUser(user);
}catch(SQLException sqle)
{
ActionMessages errors = new ActionMessages();
ActionMessage error = new ActionMessage("error.generic",sqle.getMessage());
errors.add("error",error);
saveErrors(request,errors);
}
return mapping.findForward("success");
Configure this action in the struts-config.xml as given below.
<action
attribute="loginForm"
name="loginForm"
path="/adduser"
scope="request"
type="com.visualbuilder.struts.action.AddUserAction"
validate="false" >
<forward name="success" path="/manageusers.do" />
</action>
Note that we have associated the same form bean that we did when writing the LoginAction.
Jsp Discussion
- - Two forms in one JSP
- - PASS VARIABLES BETWEEN 2
- - Table data
- - Unable to laod the image
- - The Ultimate Web UI Frame




