Struts
By Apache Software Foundation
Apache Struts is a Java web application framework that implements the Model-View-Controller pattern, providing a front-controller servlet, action classes, and XML or annotation-based configuration to structure request handling for…
Definition
Apache Struts is a Java web application framework that implements the Model-View-Controller pattern, providing a front-controller servlet, action classes, and XML or annotation-based configuration to structure request handling for enterprise applications. It was one of the most widely adopted Java web frameworks in the 2000s and remains in use in legacy enterprise systems, though it has been largely superseded by Spring MVC and other frameworks for new development.
Overview
Struts was created to address the sprawl of unstructured JSP and Servlet code that characterized early Java web development, where business logic, presentation, and request handling were often tangled together in individual JSP pages. It introduced a central `ActionServlet` (front controller) that intercepts all incoming requests, consults an XML configuration file to determine which `Action` class should handle the request, and forwards control to a JSP view once the action completes, cleanly separating the three MVC responsibilities. Mechanically, Struts 1 developers defined `struts-config.xml` entries mapping URL patterns to Action classes and JSP forwards, with `ActionForm` beans capturing and validating request parameters before they reached business logic. Struts 2, a significant rewrite that merged with the WebWork framework, replaced much of this XML-heavy configuration with annotations and interceptors, introduced OGNL expression language for data binding, and decoupled actions from the servlet API to improve testability. This rewrite means Struts 1 and Struts 2 are largely incompatible codebases despite sharing a name and lineage. Struts predates Spring MVC and helped establish MVC as the default pattern for Java web applications, but Spring MVC's tighter integration with the broader Spring ecosystem, its more testable POJO-based controllers, and its eventual bundling into Spring Boot led most new projects to choose it over Struts by the 2010s. Compared to JSF, which is a component-based UI framework abstracting away HTTP request/response details, Struts remains closer to the request/response model, giving developers more direct control at the cost of more manual wiring. In practice, Struts today is found almost exclusively in legacy enterprise applications — banking systems, government portals, and large corporate intranets — that were built during its peak adoption and have not been rewritten. Maintenance teams work with existing Struts codebases rather than starting new Struts projects, and much of the current attention on the framework relates to patching known vulnerabilities in older versions rather than adding features. The framework's most consequential limitation has been security: several critical remote-code-execution vulnerabilities were discovered in Struts 2's OGNL expression evaluation and file-upload handling over the years, some of which were exploited in high-profile breaches, making prompt patching and version currency essential for any organization still running it. Combined with its declining community activity and the maturity of alternatives like Spring MVC, Struts is now generally recommended only for maintaining existing systems, never for new application development. Organizations still running Struts in production are generally advised to keep dependencies current, monitor security advisories closely, and plan an eventual migration path rather than treat the framework as a long-term foundation, since its diminished maintenance activity means newly discovered issues may see slower fixes than actively developed alternatives receive.
Key Features
- Implements a front-controller servlet routing all requests centrally
- Separates request handling into Action classes distinct from views
- Struts 2 introduced interceptors and OGNL for data binding
- Supports XML or annotation-based configuration of action mappings
- Provides form validation through ActionForm beans in Struts 1
- Integrates with JSP and Tiles for composing reusable page layouts
- Merged with WebWork in Struts 2 for improved testability
- Widely deployed across large legacy enterprise Java applications