It’s late 2000, and building a web application in Java often feels like a step backward. We have Servlets and JSPs, but without a clear architecture, we end up with "Model 1" architecture-where JSPs are full of database queries, business logic, and HTML all mixed together. It’s a maintenance nightmare.
The Apache Jakarta project has just released Struts 1.0, and it’s exactly what we need.
The MVC Pattern
Struts implements the Model-View-Controller (MVC) pattern for the web.
- Model: Your business logic and data (EJBs, DAOs).
- View: JSPs that use the Struts Tag Library to display data.
- Controller: The
ActionServlet, which dispatches requests toActionclasses based on a configuration file.
The struts-config.xml file is the heart of the application. It maps URLs to actions and defines where the user should be sent after an action completes.
<action-mappings>
<action path="/login"
type="com.example.LoginAction"
name="loginForm"
scope="request"
input="/login.jsp">
<forward name="success" path="/welcome.jsp"/>
<forward name="failure" path="/login.jsp"/>
</action>
</action-mappings>
Form Beans
One of the best features is the ActionForm. Struts automatically populates these Java beans from the HTTP request parameters and handles basic validation. No more manually calling request.getParameter() 50 times!
Looking Ahead
Struts is the first "industrial strength" framework for Java web development. It’s going to become the standard for enterprise applications. Of course, it’s not perfect-the XML configuration can get massive, and the inheritance-based model for Actions is a bit rigid.
But compared to the chaos of "Model 1," Struts feels like a professional engineering tool. It’s teaching a whole generation of web developers about the importance of separation of concerns.
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