Adopting Struts 2.0

The framework for the next generation of Java Web applications

While the Struts framework has been widely deployed, there's no doubt that its original version held room for improvement. The newly released Struts 2.0 carries much of the power of its predecessor but is simpler for developers to use. In this article, S. Sangeetha and S. V. Subrahmanya outline the changes in Struts 2.0 and offer migration pointers for developers familiar with the Struts framework.

Apache Struts is a very popular Web framework for developing Web applications using Java Enterprise Edition (JEE). The Apache Struts Project is the open source community that develops and maintains the Struts framework. Apache Struts (or simply Struts) was released in July 2001. Since its release, it has become the de facto standard for building Web applications using JEE.

The recently released Struts 2.0 is an elegant, extensible framework for building enterprise-ready Web applications using Java code. The framework is designed to streamline the development cycle, from building to deploying to maintaining applications over time. Following an in-depth introduction to the architecture of Struts 2, you'll examine code samples that illustrate its advances over Struts 1.0, and get some tips for migrating and integrating code written for the earlier Struts framework with Struts 2.0.

This article assumes prior familiarity with Struts 1.0. If you are familiar with Model-View-Controller (MVC)-based Web development but haven't used Struts before, you may want to read "Struts 2.0 in action" (JavaWorld, October 2007) to learn the basics of Java Web application development using the Struts framework.

A brief history of Struts 2.0

The Struts framework was created so that developers could build servlets or JavaServer Pages in which database code, page design code and control flow code were not co-mingled. Applications that have code intermixed in this way become difficult to maintain as they grow larger. The Struts framework is based on the MVC architecture, which helps developers create dynamic Web applications with clear separation of concerns.

The Struts framework provides its own Web controller component for handling control-flow logic. For the view, it integrates with other technologies, such as JavaServer Pages (including JSTL and JSF), Velocity Template Engine and XSLT. For the model, it uses technologies such as JDBC, EJB, Hibernate or iBATIS for data access.

Struts 1.0 is mature, well supported by a large developer community, and widely documented. But over the last few years, a lot of open source community Web frameworks have come onto the scene, and there's been a need to keep up with the changing requirements for Web applications; thus, there has been an impetus for the creation of the next generation of the Struts framework. The initial proposal that sought to fill this need was Struts Ti, a simplified Model 2 framework for developing Web applications for those who are in need of less configuration and better structure and controller features. Another framework that was considered for this purpose was Apache Shale; however, Shale is a component-based framework that is based on JSF. The Shale developer community was hesitant to unify with Struts and has decided to continue developing Shale as a separate top-level project.

The WebWork project was started by the Open Symphony community and was aimed at the Struts developer community. It catered to the needs of people who were looking for a framework similar to Struts but with better features. The WebWork framework was released in 2002. After working independently for several years, the WebWork and Struts communities joined forces in December 2005 to create a new version of Struts; in essence, Struts 2 is Struts 1 plus WebWork. The new version of Struts is simpler to use, and closer to the original vision for the Struts framework.

1 2 3 4 5 Page
Recommended
Join the discussion
Be the first to comment on this article. Our Commenting Policies
See more