VOOZH about

URL: https://www.geeksforgeeks.org/java/introduction-and-working-of-struts-web-framework/

⇱ Introduction and Working of Struts Web Framework - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Introduction and Working of Struts Web Framework

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.

  • Integrates well with Java EE technologies such as Servlets and JSP.
  • Provides centralized request processing through a controller servlet.
  • Supports flexible and extensible application design.

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.

2. ActionForm

ActionForm is used to collect data entered by the user.

3. JSP Pages

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

4. Configuration File

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

Working of Struts Framework

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

1. HTTP Request from Client

  • A user performs an action such as clicking a link or submitting a form.
  • This generates an HTTP Request.

2. Controller (Servlet)

  • The Controller acts as the central request handler.
  • It receives all incoming requests from clients.

3. struts-config.xml

  • This configuration file contains action mappings and navigation rules.
  • It tells the controller which action class should handle a particular request.

4. Dispatch to Business Logic

  • Based on the configuration, the controller dispatches the request to the appropriate Business Logic component.
  • Business logic performs the required operations such as database access, calculations, or validations.

5. Update Model (Application State)

  • After processing, the business logic updates the Model.
  • The model represents the application's data and current state.

6. Forward to View (JSP)

  • The controller forwards the processed request to a JSP View.
  • The view retrieves data from the model using tags and JavaBeans.

7. Generate HTTP Response

  • The JSP page generates the final HTML output.
  • The response is sent back to the client browser as an HTTP Response.

Advantages of Struts Framework

  • Follows MVC Architecture: Separates business logic, presentation, and control logic, making applications easier to maintain.
  • Improves Code Reusability: Components such as Action classes and JSP pages can be reused across the application.
  • Easy Maintenance: Changes in one layer have minimal impact on other layers.
  • Built-in Form Validation: Provides validation mechanisms to reduce manual coding.
  • Supports Internationalization (i18n): Makes it easier to develop multilingual applications.
  • Centralized Request Handling: All requests are managed through a single controller servlet.
  • Rich Tag Libraries: Offers custom JSP tags that simplify UI development.
Comment
Article Tags: