Form Beans

Intertech Tutorials

Using Form Bean

ActionForm class
package com.intertech;

import org.apache.struts.action.ActionForm;

public class User extends ActionForm{
private String userName;
private String password;

public String getPassword() {
return password;

public String getUserName() {
return userName;

public void setPassword(String password) {
this.password = password;

public void setUserName(String userName) {
this.userName = userName;

public class VerifyLogon extends Action{
private int numTries;

public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception

//Get the javabean out of the action mapping to work with
User user = (User)form;

if (/*???*/){ //Success condition
return (mapping.findForward("success"));
}else if(numTries < 3){
//Non-Teminal Failure Condition
return (mapping.findForward("failure"));
//Terminal Failure Condition
return (mapping.findForward("kickout"));


Copyright (c) 2008-2013. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an online learning aid. Any attempts to copy, reproduce, or use for training is strictly prohibited.