Adding a form bean is a two step process. First of all we need to declare the form bean in the <form-beans> tag. Then we can associate this form bean to as many actions as we want. To declare the form bean,add the following line in the <form-beans> tag.
<form-bean name="loginForm" type="com.visualbuilder.struts.beans.User" />
Now we will associate this form bean with the LoginAction. Update the action tag in action-mappings so that it becomes like this.
<forward name="failure" path="/index.jsp" />
<forward name="success" path="/manageusers.jsp" />
Now update the LoginAction to retrieve form values from form bean instead of request object though they are still available in the request object s well. Execute method should look like this now.
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)
User userForm = (User)form;
String user = userForm.getUserId();
String password = userForm.getPassword();
if(user!=null && password!=null && user.equals("admin") && password.equals("admin"))
Again deploy and run the project. You should get the same behavior as you got earlier.