AboutBlogContact
Web DevelopmentMay 10, 2003 2 min read 75Updated: May 3, 2026

Java Struts 1.1: Master of the ActionServlet and Form Beans (2003)

AunimedaAunimeda
📋 Table of Contents

Java Struts 1.1: Master of the ActionServlet and Form Beans

It's 2003, and the "Spaghetti Code" of JSP files filled with JDBC calls is finally being replaced by a more structured approach. The Apache Struts framework has become the industry standard for J2EE web development. By separating our logic into Actions, our data into ActionForms, and our configuration into XML, we can finally build maintainable enterprise applications.

The struts-config.xml

In Struts 1.1, the XML configuration file is the brain of your application. It maps incoming request paths to specific Java classes.

<struts-config>
  <form-beans>
    <form-bean name="loginForm" type="com.example.forms.LoginForm" />
  </form-beans>

  <action-mappings>
    <action path="/login"
            type="com.example.actions.LoginAction"
            name="loginForm"
            scope="request"
            validate="true"
            input="/login.jsp">
      <forward name="success" path="/welcome.jsp" />
      <forward name="failure" path="/login.jsp" />
    </action>
  </action-mappings>
</struts-config>

The ActionForm: Capturing User Input

The ActionForm is a simple JavaBean that Struts automatically populates with data from the HTTP request. It’s also where we perform basic validation.

public class LoginForm extends ActionForm {
    private String username;
    private String password;

    public void setUsername(String u) { this.username = u; }
    public String getUsername() { return username; }
    
    // validation logic
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (username == null || username.length() < 1) {
            errors.add("username", new ActionMessage("error.username.required"));
        }
        return errors;
    }
}

The Action: The Controller Logic

When the user submits the form, the ActionServlet creates the LoginForm, validates it, and then passes it to your Action class.

public class LoginAction extends Action {
    public ActionForward execute(ActionMapping mapping, ActionForm form,
                                 HttpServletRequest request, HttpServletResponse response) {
        LoginForm loginForm = (LoginForm) form;
        String username = loginForm.getUsername();

        // Business logic would go here (e.g., calling an EJB or DAO)
        if ("admin".equals(username)) {
            return mapping.findForward("success");
        } else {
            return mapping.findForward("failure");
        }
    }
}

The Power of Tags

In 2003, we don't write <input type="text"> by hand. We use the Struts Tag Library. This ensures that our JSP pages are tightly coupled to our ActionForms, allowing the framework to automatically re-populate fields if validation fails. It’s a complete ecosystem that, while XML-heavy, brings much-needed order to the chaos of early Java web development.


Aunimeda develops websites and web applications for businesses - corporate sites, e-commerce, portals, and custom platforms.

Contact us to discuss your web project. See also: Web Development, E-commerce Development

Read Also

Django: The Web Framework for Perfectionists with Deadlinesaunimeda
Web Development

Django: The Web Framework for Perfectionists with Deadlines

Extracted from a high-pressure newsroom environment, Django is bringing order and speed to Python web development with its 'batteries-included' approach.

Ruby on Rails: The 15-Minute Blog and the Death of XML Configaunimeda
Web Development

Ruby on Rails: The 15-Minute Blog and the Death of XML Config

David Heinemeier Hansson has extracted a framework from Basecamp that is making Java and .NET developers look like they're working in the Stone Age.

ColdFusion MX: J2EE Integration Magic (2002)aunimeda
Web Development

ColdFusion MX: J2EE Integration Magic (2002)

ColdFusion is no longer just a set of C++ tags. With MX, it's running on Java. Let's exploit the underlying J2EE power.

Need IT development for your business?

We build websites, mobile apps and AI solutions. Free consultation.

Web Development

Get Consultation All articles