Apache Struts
Encyclopedia
Apache Struts is an open-source web application framework
Web application framework
A web application framework is a software framework that is designed to support the development of dynamic websites, web applications and web services. The framework aims to alleviate the overhead associated with common activities performed in Web development...

 for developing Java EE web application
Web application
A web application is an application that is accessed over a network such as the Internet or an intranet. The term may also mean a computer software application that is coded in a browser-supported language and reliant on a common web browser to render the application executable.Web applications are...

s. It uses and extends the Java Servlet
Java Servlet
A servlet is a Java programming language class used to extend the capabilities of servers that host applications accessed via a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by Web servers...

 API
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...

 to encourage developers to adopt a model-view-controller
Model-view-controller
Model–view–controller is a software architecture, currently considered an architectural pattern used in software engineering. The pattern isolates "domain logic" from the user interface , permitting independent development, testing and maintenance of each .Model View Controller...

 (MVC) architecture. It was originally created by Craig McClanahan
Craig McClanahan
Craig R. McClanahan is a programmer and original author of the Apache Struts framework for building web applications. He was part of the expert group that defined the servlet 2.2, 2.3 and JSP 1.1, 1.2 specifications. He is also the architect of Tomcat's servlet container Catalina.-External links:*...

 and donated to the Apache Foundation in May, 2000. Formerly located under the Apache Jakarta Project
Jakarta Project
The Jakarta Project creates and maintains open source software for the Java platform. It operates as an umbrella project under the auspices of the Apache Software Foundation, and all of Jakarta products are released under the Apache License.-Subprojects:...

 and known as Jakarta Struts, it became a top-level Apache project in 2005.

Design goals and overview

In a standard Java EE
Java Platform, Enterprise Edition
Java Platform, Enterprise Edition or Java EE is widely used platform for server programming in the Java programming language. The Java platform differs from the Java Standard Edition Platform in that it adds libraries which provide functionality to deploy fault-tolerant, distributed, multi-tier...

 web application, the client will typically submit information to the server via a web form
Form (web)
A webform on a web page allows a user to enter data that is sent to a server for processing. Webforms resemble paper or database forms because internet users fill out the forms using checkboxes, radio buttons, or text fields...

. The information is then either handed over to a Java Servlet
Java Servlet
A servlet is a Java programming language class used to extend the capabilities of servers that host applications accessed via a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by Web servers...

 that processes it, interacts with a database and produces an HTML-formatted response, or it is given to a JavaServer Pages
JavaServer Pages
JavaServer Pages is a Java technology that helps software developers serve dynamically generated web pages based on HTML, XML, or other document types...

 (JSP) document that intermingles HTML and Java code to achieve the same result.
Both approaches are often considered inadequate for large projects because they mix application logic with presentation and make maintenance difficult.

The goal of Struts is to 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
Extensible Markup Language
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

/XSLT and Velocity
Jakarta Velocity
Apache Velocity is an open source software project directed by the Apache Software Foundation. Velocity is a Java-based template engine that provides a simple yet powerful template language to reference objects defined in Java code...

 are also supported). The web application programmer is responsible for writing the model code, and for creating a central configuration file struts-config.xml that 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 that interacts with the application-specific model code. The model code returns an "ActionForward", a string telling the controller what output page to send to the client. Information is passed between model and view in the form of special JavaBeans
JavaBeans
JavaBeans are reusable software components for Java. Practically, they are classes written in the Java programming language conforming to a particular convention. They are used to encapsulate many objects into a single object , so that they can be passed around as a single bean object instead of as...

. 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 is categorized as a request-based web application framework.

Struts also supports internationalization
Internationalization and localization
In computing, internationalization and localization are means of adapting computer software to different languages, regional differences and technical requirements of a target market...

 by web forms, and includes a template mechanism called "Tiles" that (for instance) allows the presentation layer to be composed from independent header, footer, and content components.

Struts2 features

  • Simple POJO
    Pojo
    Pojo may refer to:* Pohja, the Swedish name for the Finnish municipality* POJO, abbreviation of Plain Old Java Object in computer programming...

     based Actions
  • Simplified testability
  • Thread Safe
  • AJAX
    Ajax
    - Mythology :* Ajax , son of Telamon, ruler of Salamis and a hero in the Trojan War, also known as "Ajax the Great"* Ajax the Lesser, son of Oileus, ruler of Locris and the leader of the Locrian contingent during the Trojan War.- People :...

     Support
  • jQuery Plugin
  • Dojo Plugin (deprecated)
  • AJAX Client Side Validation
  • Template Support
  • Support for different result types
  • Easy to extend with Plugins
  • REST
    Rest
    Rest may refer to:* Leisure* Human relaxation* SleepRest may also refer to:* Rest , a pause in a piece of music* Rest , the relation between two observers* Rest , a 2008 album by Gregor Samsa...

     Plugin (REST based Actions, Extension-less URLs)
  • Convention Plugin (Action Configuration via Conventions and Annotations)
  • Spring Plugin (Dependency Injection
    Dependency injection
    Dependency injection is a design pattern in object-oriented computer programming whose purpose is to improve testability of, and simplify deployment of components in very large software systems....

    )
  • Hibernate Plugin
  • JFreechart Plugin (Charts)
  • jQuery Plugin (AJAX Support, UI Widgets, Dynamic Table, Charts)
  • Rome Plugin (RSS Feeds)

Competing MVC frameworks

Although Struts is a well-documented, mature, and popular framework for building front ends to Java applications, there are other frameworks categorized as "lightweight" MVC
Model-view-controller
Model–view–controller is a software architecture, currently considered an architectural pattern used in software engineering. The pattern isolates "domain logic" from the user interface , permitting independent development, testing and maintenance of each .Model View Controller...

 frameworks such as Spring MVC
Spring Framework (Java)
The Spring Framework is an open source application framework for the Java platform.The first version was written by Rod Johnson, who released the framework with the publication of his book Expert One-on-One J2EE Design and Development in October 2002. The framework was first released under the...

, Stripes
Stripes (framework)
-External links:********...

, Wicket, Play!
Play Framework
Play is an open source web application framework, written in Java, which follows the model-view-controller architectural pattern. It aims to optimize developer productivity by using convention over configuration, hot code reloading and display of errors in the browser.Although Play is written in...

, and Tapestry
Tapestry (programming)
Apache Tapestry is an open-source component-oriented Java web application framework to implement applications in accordance with the model-view-controller architectural pattern. Tapestry was created by Howard Lewis Ship independently, and was adopted by the Apache Software Foundation as a top-level...

. The new XForms
XForms
XForms is an XML format for the specification of a data processing model for XML data and user interface for the XML data, such as web forms...

 standards and frameworks may also be another option to building complex web Form validations with Struts in the future.

The WebWork
WebWork
WebWork was a Java-based web application framework developed by OpenSymphony that merged into the current Struts2 framework. It was developed with the specific intention of improving developer productivity and code simplicity...

 framework spun off from Apache Struts aiming to offer enhancements and refinements while retaining the same general architecture of the original Struts framework. However, it was announced in December 2005 that Struts would re-merge with WebWork
WebWork
WebWork was a Java-based web application framework developed by OpenSymphony that merged into the current Struts2 framework. It was developed with the specific intention of improving developer productivity and code simplicity...

. WebWork 2.2 has been adopted as Apache Struts2, which reached its first full release in February 2007.

In 2004, Sun launched an addition to the Java platform, called JavaServer Faces
JavaServer Faces
JavaServer Faces is a Java-based Web application framework intended to simplify development integration of web-based user interfaces....

 (JSF). Aside from the original Struts framework, the Apache project previously offered a JSF-based framework called Shale
Shale Framework (software)
Shale is a web application framework maintained by the Apache Software Foundation. It is fundamentally based on JavaServer Faces. As of May 2009 Apache Shale has been retired and moved to the Apache Attic.-External links:***...

, which was retired in May 2009.

Other MVC frameworks that are Java based include WebObjects
WebObjects
WebObjects was a Java web application server from Apple Inc., and a web application framework that ran on the server. It was available at no additional cost. Its hallmark features were its object-orientation, database connectivity, and prototyping tools...

 and Grails
Grails (Framework)
Grails is an open source web application framework which uses the Groovy programming language . It is intended to be a high-productivity framework by following the "coding by convention" paradigm, providing a stand-alone development environment and hiding much of the configuration detail from the...

.

See also

  • Model-view-controller
    Model-view-controller
    Model–view–controller is a software architecture, currently considered an architectural pattern used in software engineering. The pattern isolates "domain logic" from the user interface , permitting independent development, testing and maintenance of each .Model View Controller...

  • Jakarta Project
    Jakarta Project
    The Jakarta Project creates and maintains open source software for the Java platform. It operates as an umbrella project under the auspices of the Apache Software Foundation, and all of Jakarta products are released under the Apache License.-Subprojects:...

  • Java EE
    Java Platform, Enterprise Edition
    Java Platform, Enterprise Edition or Java EE is widely used platform for server programming in the Java programming language. The Java platform differs from the Java Standard Edition Platform in that it adds libraries which provide functionality to deploy fault-tolerant, distributed, multi-tier...

  • JavaServer Faces
    JavaServer Faces
    JavaServer Faces is a Java-based Web application framework intended to simplify development integration of web-based user interfaces....

  • Stripes
    Stripes (framework)
    -External links:********...

  • Comparison of web application frameworks
    Comparison of web application frameworks
    This is a comparison of notable web application frameworks.-Perl:-PHP:-Java:-Python:-Ruby:-CFML :-ASP.NET:-Other:-ASP.NET:-C++:-CFML:-Python:-Java:-PHP:-Ruby:-Others:...

  • ZK Framework

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK