Introduction and Working of Struts Web Framework (original) (raw)

Last Updated : 10 Jun, 2026

Apache Struts is an open-source web application framework developed by the Apache Software Foundation for building Java-based web applications. It is based on the MVC (Model-View-Controller) architecture, which separates business logic, presentation logic, and user input handling into different components.

Struts Framework Architecture

Shows how a client request flows through the Controller, Model, and View components in the Struts MVC framework.

Working Flow of Struts

The diagram illustrates how a request flows through the Struts MVC framework.

Components of Struts Framework

The main components of the Struts framework are:

1. Action Class

An Action class processes user requests and executes business logic.

Java `

public class LoginAction extends Action {

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

    return mapping.findForward("success");
}

}

`

2. ActionForm

ActionForm is used to collect data entered by the user.

Java `

public class LoginForm extends ActionForm {

private String username;
private String password;

public String getUsername() {
    return username;
}

public void setUsername(String username) {
    this.username = username;
}

}

`

3. JSP Pages

JSP pages are used to display information and collect user input.

Java `

<html:form action="/login"> Username: <html:text property="username"/>

Password:
<html:password property="password"/>

<html:submit value="Login"/>

`

4. Configuration File

The struts-config.xml file defines mappings between requests and action classes.

Java `

    <forward
        name="success"
        path="/success.jsp"/>
</action>

`

Working of Struts Framework

The working of Struts can be understood through the following steps:

1. HTTP Request from Client

2. Controller (Servlet)

3. struts-config.xml

4. Dispatch to Business Logic

5. Update Model (Application State)

6. Forward to View (JSP)

7. Generate HTTP Response

Advantages of Struts Framework