 |
Apache Struts
Apache Struts is an MVC (Model View Controller) framework for building web applications. It was created by Craig McClanahan and is
supported by many JavaIDEs. Some say it is the de facto framework for building web applications; regardless, it does make life easier. There are
many other good frameworks deserving a good look like Velocity, Turbine, Cocoon, and Barricuda to name a few.
When selecting an open source framework the people who develop the framework are just as important as the technology. Also disregard
the version number, there are many top quality actively developed projects that have been around for years and haven't even reached
version 1.0--Castor comes to mind.
There are also a few products that are at version 4.0 that have only been around for 8 months and are poorly tested and documented.
An external Wiki is here: http://wiki.apache.org/struts/FrontPage
A Struts PlugIn? for Eclipse and JBuilder is Easy Struts, which offers everything to create Struts applications.
Books
Articles
See Also
Discussion about Struts
Is Struts mediocre?
Arguments in favor of this proposition:
- the execute method is a dubious implementation of the Command pattern, since it has many arguments. A recurring theme of design patterns is that the central methods of any design are free of implementation details. That is, signatures of important methods are very "clean". Data required by implementation classes is usually passed into the constructor. In struts, however, everything is passed to the
execute method as a parameter. If the implementation does not use a particular item (such as the response object) then it still passed in anyway.
- the custom HTML tags used for user input items such as radio buttons and check boxes are invasive in the extreme. Struts forms depart widely from standard HTML. This is neither desirable nor necessary. Alteration of standard HTML should be kept to an absolute minimum. Prepopulation of form input items can be accomplished in a much more elegant, non-intrusive manner. See, for example Prepopulate. (It is true that this Prepopulate tag unnecessarily restricts its content. That is a valid criticism, and it needs improvement. However, this does not change the fact that the idea behind the Prepopulate tag, whereby standard HTML undergoes minimal change, is an order of magnitude better than the explosion of custom HTML form tags found in struts. Think of the Prepopulate tag as a "proof of concept", if you wish.)
- action objects are cached. This is apparently a performance optimization. Designs in which an action holds a heavyweight object (such as a long-lived database connection), however, seem to be of dubious quality. If actions should be light-weight, then they are just another object. Have you seen the size of stack traces from Tomcat? What difference would some caching some light-weight action object really make? Nil.
- actions must be thread-safe. (See above). As explained in Effective Java (Bloch), ensuring that a class is thread-safe imposes a non-trivial task upon the implementor. If the caching was removed, the extra and apparently unnecessary burden of ensuring the thread-safety of every action could be removed.
- actions need to do a cast to obtain the correct ActionForm, leading to runtime errors
- it does nothing for the back-end. Application programmers typically need to build both a front- and back-end. If a tool such as Struts assists only in building the front-end, then it is helping to solve only half the problem. Strictly speaking, it is a front-end framework, not an application framework. (The fact that the front- and back-ends are independent is not relevant in this regard; the application programmer still has to build both, regardless of their independance.)
- Does it verify that all param names are known to the application, as a basic check against malicious attacks? I don't think it does. One may always add this, but since security is so important, a framework should compel one to do so.
- the action mapping has wildcards, but cannot use regular expressions
- a front-end framework for web apps should be even simpler than struts
-- JohnOHanley - 20 Oct 2003
|