Thanks everyone. Remove everything from the action and found out that my code never made it there. I change the code to the following.
I am new trying to understand. thanks
package input;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import login.LoginBean;
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 org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError;
public class AddAddressAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Default target to success
String target = new String("success");
if ( isCancelled(request) ) {
// Cancel pressed back to employee list
return (mapping.findForward("success"));
}
if (request.getParameter("add") != null)
{
/* start */
try {
Address address = new Address();
AddressForm addressform = (AddressForm) form;
address.setfName(addressform.getfName());
address.setLname(addressform.getLname());
address.setStreet(addressform.getStreet());
address.setCity(addressform.getCity());
address.setState(addressform.getState());
address.setZip(addressform.getZip());
// address.setType(addressform.getType());
// address.setUsername(addressform.getUsername());
AddressData.addAddress(address, getDataSource(request, "address"));
//= new LoginBean(getDataSource(request, "address"));
}
catch ( Exception e ) {
System.err.println("Setting target to error");
target = new String("error");
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("errors.database.error", e.getMessage()));
// Report any errors
if ( !errors.isEmpty() ) {
saveErrors(request, errors);
}
}
/* end */
target = new String("add");
return (mapping.findForward("add"));
}
// Forward to the appropriate View
target = new String("missed");
return (mapping.findForward("missed"));
}
}