Getting Started with Apache Struts
Tutorial - Apache Struts 2 - From Soup to Nuts
Apache Struts 2 simplifies enterprise-ready web development by providing a flexible set of custom tags and an extensible application architecture. The framework is designed for professional developers creating sophisticated web applications that integrate with databases and other enterprise services. Originally known as WebWork, Struts 2 has been continuously maintained since March 2002, and most recently updated with the April 2012 release (2.3.3). Struts 2 is product of the Apache Software Foundation and distributed to the general public at no charge under the business-friendly Apache Software License 2.0. The ASF provides product support only through a public mailing list frequented by volunteer developers and users.
Struts 2 is directly supported by the three most popular integrated development environments (IDEs) for Java: IntelliJ IDEA by JetBrains, MyEclipse by Genutec, and NetBeans. For example, to create a Struts 2 application in IntelliJ IDEA, you can select the Struts 2 facet, and the IDE will download the JARs and setup a Java web application structure, ready for you to add your own pages and other Struts 2 elements.
Figure 1 - IntelliJ IDEA ready for your Struts 2 elements
Likewise, with MyEclipse, you can add Struts 2 capabilities to a web project, including wizards to create new Struts 2 elements or edit existing elements. The wizards are context-sensitive and provide input assistance and validation as you edit Struts 2 elements. Not to be left behind, NetBeans offers its own set of wizards to create an example Struts 2 application, register the necessary library files, and then edit the various Struts 2 elements. In addition, NetBeans supports hyperlinking and code completion in Struts 2 configuration files. Struts 2 also provides a Maven prototype you can use to bootstrap a project, if you are so inclined, and, of course, the distribution has all the usual assets for hardcore hand-coders.
In Brief – The Elements of Struts Design
A dynamic Struts 2 application has seven building blocks:
- Pages with Struts Tags
- Message Properties
- Annotations and Deployment Descriptors
The elements can be organized into three groups:
- Pages and Message Properties are used to create the application user interface.
- Actions, Interceptors, and Validators process an incoming request, in order to render a page, or some other Result.
- Annotations and Deployment Descriptors are used to define the initial state for the other elements of a Struts 2 application.
Let’s take a look at each element in turn...