Struts is an MVC framework for Java web application development. Struts 1.0 was released in July 2001, roughly a year before ASP.NET 1.0. Currently, 70-80% of Java Web application developer's job requires Struts so it is fair to say that Struts is the current mainstream framework for Java web application.
Struts contains an MVC framework and a set of JSP custom tags. For a simplest application, developers need to provide:
- An html form in which user can enter data.
- A Struts bean that serves as model. The inputs in the form is mapped to the properties of the bean.
- An action servlet which serves as controller.
- One or more JSP pages that serves as view for the results.
The components are wired together with a configuration file struts-config.xml. Struts framework actually provides a servlet as front-controller in which all actions go to. The front-controller is responsible for instantiate the Struts bean, dispatch the action and route to the approprate view based on the return of the action.
In addition, Struts also supplies custom JSP tags that provides the following functionalities:
- Preserve the state of input if the view is same as the form.
- Layout with Tiles.
Struts provides serveral important functionalities in the framework and significantly reduced the repeatitive tasks in Java web development. ASP.NET does not require a regid MVC pattern like Struts (which could be both pro and con). Besides that, ASP.NET does almost every other things better:
- Struts still requires coding the same information twice, once in form and the second time in bean. In ASP.NET code-behind, controls are automatically created from form. In additional, ASP.NET supports rich controls, i.e., controls not available in HTML.
- The modle, view and controller of Struts is scattered in many files. The only place to find them is in the struts-config.xml file. It is inconvenient to work with large number of files. Although the seperation of functionalities into many classes remotes reuse, in reality, the classes are rarely reused.
- ASP.NET's mechanism to preserve form state is simpler to use.
- ASP.NET's master page and skin is superior to Tiles.
In conclusion, also Struts is a significant improvement over normal JSP/Serlet programming. Struts is still far behind ASP.NET in functionality and productivity. There are tools like AppFuse that would make Struts development easier. It is still nowhere near the experience with Visual Studio 2005 and ASP.NET 2.0.
Perhaps it is time to compare ASP.NET with JSF which is the latest offering in the Java world.