Misplaced Pages

Apache Struts 1: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editNext edit →Content deleted Content addedVisualWikitext
Revision as of 12:10, 25 March 2007 edit213.195.207.53 (talk) External links← Previous edit Revision as of 18:06, 4 April 2007 edit undo218.186.9.5 (talk) External links: Added link for Struts TutorialsNext edit →
Line 53: Line 53:
==External links== ==External links==
* *
*
* *
* *

Revision as of 18:06, 4 April 2007

Apache Struts
Apache Struts Logo
Developer(s)Apache Software Foundation
Stable release2.0.6 / February 22, 2007
Repository
Operating systemCross-platform
TypeWeb Framework
LicenseApache 2.0 license
Websitestruts.apache.org

Apache Struts is an open-source framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model-view-controller (MVC) architecture. It was originally created by Craig McClanahan and donated to the Apache Foundation in May, 2000. Formerly located under the Apache Jakarta Project and known as Jakarta Struts, it became a top level Apache project in 2005.

Design goals and overview

In a standard Java EE web application, the client will typically submit information to the server via a web form. The information is then either handed over to a Java servlet which processes it, interacts with a database and produces an HTML-formatted response, or it is given to a JavaServer Pages (JSP) document which intermingles HTML and Java code to achieve the same result. Both approaches are inadequate for large projects because they mix application logic with presentation and make maintenance difficult.

The goal of Struts is to cleanly separate the model (application logic that interacts with a database) from the view (HTML pages presented to the client) and the controller (instance that passes information between view and model). Struts provides the controller (a servlet known as ActionServlet) and facilitates the writing of templates for the view or presentation layer (typically in JSP, but XML/XSLT and Velocity are also supported). The web application programmer is responsible for writing the model code, and for creating a central configuration file struts-config.xml which binds together model, view and controller.

Requests from the client are sent to the controller in the form of "Actions" defined in the configuration file; if the controller receives such a request it calls the corresponding Action class which interacts with the application specific model code. The model code returns an "ActionForward", a string telling the controller which output page to send to the client. Information is passed between model and view in the form of special JavaBeans. A powerful custom tag library allows it to read and write the content of these beans from the presentation layer without the need for any embedded Java code.

Struts also supports I18N (internationalisation), provides facilities for the validation of data submitted by web forms, and includes a template mechanism called "Tiles" which (for instance) allows to compose the presentation layer from independent header, footer and content components.

Competing MVC frameworks

Although Struts is a well documented, mature and popular framework for building front ends to Java applications, it is facing new challenges from newer "light weight" MVC frameworks such as Spring, Stripes and Tapestry. The new XForms standards and frameworks may also be another option to building complex web Form validations with Struts in the future.

In December 2005, Struts joined forces with another popular J2EE framework, WebWork. WebWork is being adopted as the 2.0 release of Apache Struts. WebWork spun off from Struts several years ago, and offers many enhancements and refinements, while retaining the same general architecture of the original Struts framework. The merge of Struts and WebWork is known as Struts 2, in general availability .

Sun recently brought out a new addition to the Java platform, called JavaServer Faces (JSF). Aside from the original framework, the Apache Struts project also offers a JSF-based framework called Shale.

Other MVC frameworks that are not J2EE based include Ruby on Rails, WebObjects, Django, Catalyst, TurboGears, CakePHP, CodeIgniter (for PHP). Struts4php is a version of the Struts framework for the PHP web scripting language.

See also

References

  • James Holmes: Struts: The Complete Reference, McGraw-Hill Osborne Media, ISBN 0-07-223131-9
  • Bill Siggelkow: Jakarta Struts Cookbook, O'Reilly, ISBN 0-596-00771-X
  • James Goodwill, Richard Hightower: Professional Jakarta Struts, Wrox Press, ISBN 0-7645-4437-3
  • John Carnell and Rob Harrop: Pro Jakarta Struts, Second Edition, Apress, ISBN 1-59059-228-X
  • John Carnell, Jeff Linwood and Maciej Zawadzki: Professional Struts Applications: Building Web Sites with Struts, ObjectRelationalBridge, Lucene, and Velocity, Apress, ISBN 1-59059-255-7
  • Ted Husted, etc: Struts in Action, Manning Publications Company, ISBN 1-930110-50-2
  • Struts View Assembly and Validation, (PDF format).
  • Stephan Wiesner: Learning Jakarta Struts 1.2, Packt Publishing, 2005 ISBN 1-904811-54-X

External links


The Apache Software Foundation
Top-level
projects
Commons
Incubator
Other projects
Attic
Licenses
Categories: