You might ask, "Why do I need to know about Struts. Why are they important to Web applications?" Simply put, the Struts framework provides a common architecture and a set of services for developing the key elements of Java Web applications. Advantages to using Struts in Web applications:
* They promote the reuse of application logic
* They separate presentation, logic and control
* They make modular applications more maintainable
* Struts actions are configurable at runtime
WebSphere Development Studio Client (WDSC) provides a variety of tools, wizards and editors to make it easier and more productive to build Struts applications, especially for developers new to Struts. Lets take a look at those tools and their functionality.
Struts tools included in WDSC version 5
- Web project wizard
- ActionForm wizard
- Struts configuration file wizard and editor
- ActionMapping editor
- Action class wizard
- Struts JSP wizard
- Page Designer JSP editor with Struts tag support
- Struts module wizard and editor
- Web diagram tool for maintaining visually a Struts application workflow
- WebSphere test environment for testing your Struts application
WDSC also provides strong support for building, testing and packaging all the other elements of your Struts web application as well: HTML pages, resources (image files), Java beans, etc.
Web project wizard
The Web project wizard supports adding the Struts resources required for a Struts version 1.02 or 1.1 application: jar files and JSP tag library descriptor files in the appropriate location. As an alternative, Apache supplies a blank.war file for Struts that contains the Struts resources already set up in the proper application structure as the starting point for defining your Struts application project.
The ActionForm wizard builds a subclass of ActionForm. It allows you to select form elements from any Struts JSP to consolidate in the ActionForm.
Action class wizard
This is really the standard class wizard to create a new class. By default, it is set to create a subclass of ActionForm. This has little impact on development.
Struts configuration file wizard and editor
This special wizard and editor creates and maintains a Struts configuration file. Especially for new developers, it improves productivity and quality building a Struts configuration. You can access the straight XML source if you are more familiar with Struts configurations. If you're new to Struts, the separate pages defining Action mappings, Global forwards, Form beans and Data Sources will make it easier to create and edit these Struts definitions accurately. However, you still need to understand what these Struts elements are.
The Struts configuration editor makes it easy to view the Actions, Form beans and Global Forwards that make up the workflow in our Registration application.
The ActionMapping editor lets you create and edit an ActionMapping in a Struts configuration file. New developers will find it easier than trying to correctly enter the mappings directly as XML elements. Specific attributes such as ActionForms and JSPs are easy to find and select using Browse buttons and drop-down list boxes.
Struts JSP wizard
This is the standard JSP wizard to create a new JSP that now supports adding Struts tag library directives, references to the ActionForm bean and Action classes.
Page Designer JSP editor with Struts tag support
Page Designer allows you to insert and edit custom Struts JSP tags reasonably productively. URLs are easy to set on Struts hyperlinks and form actions, and Page Designer can dynamically link to messages in the ApplicationResources.properties file.
You'll find that the design and source views work well with Struts tags. The preview mode doesn't support access to dynamic resources such as the messages in the ApplicationResources properties, so you won't find it useful to view what your JSPs will look like at runtime.
There were some issues referencing resources in modules other the default module in URLs in Page Designer in WDSC version 5.0. This problem MAY be addressed in service pack 5.01, but we didn't test that.
Struts module wizard and editor
This wizard allows you to create and edit module definitions for a Struts application (a Struts 1.1 feature that makes Struts applications scale well).
Web diagram tool for maintaining visually a Struts application workflow
The web diagram editor provides a visual layout tool to define Struts application objects and their relationships. The same information is available in your Struts configuration file and can be accessed by the Struts configuration file editor.
We built our Registration Struts application easily without using the Web diagram editor. Later we went back and built it again using the diagram editor. Did it make any significant difference? Not really.
Where might the Web diagram editor pay off? If you're a new Struts developer and prefer visual layout tools that show connections as arrows, you'll like using the Web diagram editor over the Struts configuration file editor. More experienced developers may prefer the Struts configuration file editor.
Both tools share some similarity: They both update a Struts configuration file and both can work with subsets of the Struts application configuration (making it easier for developers to work on larger applications). You can also define Struts components in both tools BEFORE they are created. If they exist, configurations are easier because they can be selected via a Browse button to add to the configuration. The diagram editor will change colors to reflect whether a defined Struts component exists which can make it easier to know which elements still have to be created.
WebSphere test environment for testing your Struts application
The WebSphere test environment does not have any special Struts features, BUT it is a key tool for easily testing, debugging and profiling your Struts applications. We found it possible to trace, log and profile Struts applications running in remote WebSphere or Tomcat servers; however, the WebSphere test environment was the easiest to debug.
Deployment to runtime environments: Apache Tomcat 4.1.24, WebSphere v 5.0 and WebSphere Express v 5.0 was easy. If possible, avoid using earlier versions of the Web application servers with Struts 1.1 applications. You may have to set custom classpaths.
Learning more about Struts
- If you have WDSC version 5, use the online help to learn about the Struts tools in WDSC. Also, load and test the sample Struts application from Apache that WDSC includes: struts-example.war. It is a simple log-on application, but it does a good job of introducing basic Struts development concepts. To find out more about WDSC version 5, check IBM's Web site.
- For free QuickWebTips, downloadable tutorials on how to build applications using WDSC version 5, visit www.quickwebsupport.com (enrollment is free). A future tutorial will cover building a very simple Struts application.
- "Struts In Action" by Ted Husted et al (ISBN 1-930110-50-2) offers complete coverage of Struts and how to use it in applications. It DOES NOT teach the basics on J2EE Web applications (e.g. what is a JSP tag) or how to use Struts in IBM's WDSC tools.
---------------------------------------About the author: ebt-now
- Produce more flexible Web apps using Struts
You know how important struts are to a car, but struts for Web development? If you're building Web applications -- or looking to -- you should know about the Apache Struts framework. Many companies, including IBM, are standardizing Web applications around the Struts framework to lower development costs and produce more flexible Web applications.
- Custom JSP tags speed Web development Building Web applications doesn't have to be hard, according to Web development experts Jim Mason and David Slater. This week they show you how to build and use custom JSP tags in WebSphere Development tools to build scalable Web applications easily. Follow their step-by-step instructions and get background information in this tutorial.
- WDSC: How to build a Java Web application calling RPG
Web development expert Jim Mason says IBM's WDSC tools offer the fastest, easiest way to Web-enable your existing applications for e-business. In this tip he shows you how to take an existing RPG and CL program you've created and Web-enable them with the Web Interaction wizard in WDSC.