AWS News Blog

Amazon DevCon – Craig McClanahan

Voiced by Polly

The title of the presentation is, “Struts and JavaServer Faces,” given by Craig R. McClanahan, Senior Staff Engineer at Sun Microsystems. He’s here to tell the audience everything there is to know about Struts.

Craig’s current position is as an architect for the Java Studio Creator. Earlier, he was the creator of the Struts framework. Craig does a lot of presentations and will “sub-class” his standard presentation for today.

Now that JavaServer Faces is out, does that mean that Struts is obsolete? Not yet, but perhaps in the long term. More to come.

Struts started by Craig “scratching my own itch.” He was familiar with Java and open source software, but there was no frameworks available. He has the 0.91 version of the JSP specification framed at home (perhaps above the fireplace mantle?). The model of struts was determined in the late 90s; a home-grown architecture based on the Model-View-Controller (MVC) design pattern. Interestingly, the Small Talk folks aren’t very happy about the use of the term MVC with Java Struts, when–in fact–the implementation is slightly different.

Craig showed a few diagrams of how the MVC pattern is implemented in Struts.

Model tier–Struts includes only minimal features, but you can integrate any desired approach. Too many frameworks try to be everything for everyone.

View tier–Form beans collect the server-side state of input fields on a form. A validation framework are always enforced on the server side. Struts embraced JSTL and did not try to compete with it. A tiles framework allows templating for a common look and feel, with advanced features for sharing information between tiles.

Controller tier–There’s mapping URLs to Action classes and mapping logical Forwards to physical pages. It’s important that this is separate, because it is the linkage that separates dependencies. The key is making an application more amenable to change.

Struts today can be dropped into any Servlet 2.2 or JSPP 1.1 container. Backwards compatibility is very critical to a lot of people, especially some Fortune 500 companies. “If your users care about backwards compatibility, listen to them.”

There’s a significant amount of overlap between Struts and JavaServer Faces. JavaServer Faces is a server side user interface component framework for Java-based web applications.

Craig was the specifications lead for JSF 1.0 (no wonder it’s like Struts!). One of the barriers of Java technology is getting to the Hello World application. There are powerful foundational technologies to make this easier, but there are no common component standards–that’s where JavaServer Faces comes in.

Web applications represent a key opportunity to attract a new developer market segment to Java. With that in mind, these fundamental requirements were created for JSF:

  • Accessible to corporate developers
  • Accessible to tools
  • Client device neutral
  • Usable with or without JSP
  • Usable with or without HTML
  • Scalable to enterprise applications

JSF allows application developers to specific event behavior, and have it instantly rendered into any presentation language (like HTML or WML). There are value binding expressions, which are used to bound components to a model tier value, using something like this:

#{customer.address.city}

(Note that the syntax is based on the JSTL/JSP 2.0 expression language. The goal is to synchronize these to have a single expression language.)

JSF has a backing bean concept, similar to ASP.Net‘s “code behind files”.

Again, Struts or JavaServer Faces?

Long answer on Craig’s blog on http://blogs.sun.com. There’s a Struts+Faces integration library available at Apache. The converted application will use JSF components, but not a JSF lifecycle. Application can be converted later, if desired.

There’s more than one right answer to choosing between a pure Struts-based architecture, a JSF-based architecture, or a combination. However, if you have time to learn and use JSF, give that a shot. A hybrid solution is not recommended.

Q: What’s the long-term direction?

A: Struts 1.x is a robust, mature framework. It’s time for Struts to harvest what we’ve learned over the years. It embraces JSF and the good ideas from other frameworks. Craig has proposed a new architecture for Struts 2.x, called “Shale”. Shale has not yet been accepted by the Struts developers as the formal choice for the next generation. Discussions continue on the developer list. Subscribe to the developer list to participate.

Modified 10/23/2020 – In an effort to ensure a great experience, expired links in this post have been updated or removed from the original post.
Jeff Barr

Jeff Barr

Jeff Barr is Chief Evangelist for AWS. He started this blog in 2004 and has been writing posts just about non-stop ever since.