What is it?
The
open source community has contributed a number of MVC
(Model/View/Controller)-based web application frameworks for
Java. Best known and probably still the most widely used is
Struts, but
Spring also
figures alongside Struts and Hibernate in the portfolio required
from Java developers.
Another, Tapestry, is gaining momentum. Spring and Tapestry are
both intended to be more lightweight than Struts.
Struts itself has spawned Struts 2, which diverged for a year or
two as Webwork before returning to the fold, with the claim that it
is "simpler to use and closer to how Struts was always meant to
be".
The advantage of the
MVC approach over traditional Java EE web application
development is that by separating the view (user interface) from
the controller (the navigational code) and model (the data), and
the Java from the HTML, it makes the maintenance, updating and
reuse of applications much simpler. Frameworks also help to ensure
a consistent approach to development, which is a considerable help
when a new generation takes over the task of maintaining an
application.
A new generation, even lighter-weight framework, Trails, builds
on Tapestry in the same way that IBM and others are building
lightweight development platforms on Rails.
Where did it originate?
Struts is maintained by the Apache Software Foundation, although
was developed by a Sun employee, Craig McClanahan. Tapestry,
developed by Howard Lewis Ship, who created the HiveMind services
and configuration microkernel, is also managed by the Apache
Foundation.
Spring was originally developed by Rod Johnson while working as
an IT consultant in the City. It is now managed and maintained by
the company Springsource, which has released a .net
implementation.
What is it for?
The Struts framework has three key components: a request handler
mapped to a standard URI, a response handler that transfers control
to another resource which completes the response, and a tag library
that enables developers to create interactive form-based
applications with server pages.
The Struts approach fits well with "RESTful" web service
development.
Spring brings together "best practice" and techniques from well
beyond the Java community. Champions see this as a strength others
are concerned by the move away from the traditional programming
model.
Spring is often used with Struts: the MVC approach means that
for example a Spring middle layer can be combined with a web tier
based on Struts or Tapestry.
Tapestry brings a strict object-oriented approach to Java
application development. Applications are divided into a set of
pages, each constructed from components, using XHTML templates,
small amounts of Java code and sometimes XML descriptor files.
Unlike Struts and Spring, Tapestry emphasises ease of development:
"The simplest choice should be the correct choice."
What makes it special?
These frameworks make as much use as possible of existing skills
like the Java Servlet API, the Hibernate persistence and query
service, and Integrated Development Environments such as Eclipse,
IDEA and NetBeans.
How difficult is it to master?
Not for beginners: you will need an understanding of the major
Java concepts, HTML and HTTP, and perhaps Ajax, REST and SOAP
too.
Rates of pay
Many senior
Java developer jobs now specify Struts and Spring.
Training
For Struts, see
struts.apache.org. For
Spring, see
www.springsource.com, and Rod Johnson's book Expert One-on-One J2EE
Design and Development. For
Tapestry, see
tapestry.apache.org. See also
IBM's
Developerworks,
Sun's
java.sun.com/developer, DevShed and Sourceforge.