You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Randall Parker <ra...@nls.net> on 2001/02/16 18:20:27 UTC

Velocity vs FreeMarker vs Struts vs WebWork

Folks,

I'm having a discussion with a friend about which method to use to generate HTML pages. Yes, its an eternal debate. He, in turn, is passing along comments and arguments to yet another guy he works 
with. I'd like some reaction to the points they are makign as we are trying to choose which tool to use.

Here's the first message and then two other messages below commenting on Struts, WebWork, etc.I'd be curious to know why you think we have any misperceptions about the relative advantages of 
Velocity vs the others.

Also, does the current Velocity doc describe the scarab version?

-------------
first message:
-------------

His question for people advocating a template approach is: How do you abstract the whole site's interaction and navigation from page to page, etc. He agrees completely that for small sites with one or 
two people putting them together, template engines are clearly superior and allow one to get the most done in the shortest amount of time. He just feels that as apps become more complex, the ease-of-
use of custom tags and the abstraction of every piece of the MVC framework by Struts makes for a more flexible and easier to maintain application. I can see his point, and as Craig M. is behind the 
whole Struts effort, the quality of the project is extraordinarily high.

Looking at Velocity, I don't like the syntax. Freemarker's use of <keyword> </keyword> would be much more natural to page creators. The simple "." accessor mechanism is like falling off a truck. The 
very small set of keywords is significant, as it enforces a "no-scriptlet" approach the template pages. And perhaps other approaches do something similar, but the concept of supplying the model to the 
view as a tree of various types of data, collections, etc. seems to be brilliant.

I'm going to look at WebWork a little more to see how much it's based on tag libraries as opposed to a template language. Tag libraries are part of the standard and would be far preferable to a 
"proprietary" (regardless of the license) template language.

----------
and in a later message:
----------

I just made a cursory perusal of the WebWork documentation in the download. From that, it appears to be ***a lot*** like Struts. The "Dispatcher" servlet is analogous to Struts' "ActionServlet". And 
WW's "Action" objects correspond to Struts' Action objects. There's also a somewhat extensive tag library. In short, it's not a template-based approach.

Here's the big difference that I see. The "bean" that is implicitly reference by a WW "property" tag is the Action object itself. There may be more flexibility than that, but their first simple doc example 
demonstrates this. Thus your controller is coupled with your model.

In Struts, your Action objects are passed ActionForm objects which have been prepopulated with passed data and which are tied to the session (thus they can get passed to the next Action object in a 
series of pages). These ActionForms are the "beans" in which you, at the highest level anyway, place your model logic. The Struts custom tags will access that bean to retrieve data for the page. Also, 
Struts formalizes the returning of the page/object to which the servlet should go after calling the Action. And this is typically specified in the Struts app's configuration file rather than being hard-coded in 
the Action object.

The result is a more complex (but eminently more flexible) API. The model beans are usable by any number of different Action objects at any point in the session lifecycle.

----------
and in an earlier message:
----------

Struts is a framework implementing the model 2 MVC approach to JSP. It's a
very nice framework and makes it easy to quite rigorously keep presentation
separated from business logic. Part of it is a robust set of custom tags to
generate forms which work with the framework, etc. I can see what the other
person was saying about getting notified of events, etc. But it seems to me
he could accomplish what he wanted via multiple forwards in a single
request. Servlets 2.3 also formalize a filtering mechanism which may provide
for more granular handling of various aspects of a request. Certainly,
custom tag libraries are a key piece of any JSP application which wants to
minimize or eliminate scriptlets from the pages.  FWIW, as the lead Struts
guy (Craig McLanahan sp?) is at Sun and works on Tomcat, folks seem to agree
that a) it has tons of momentum and mindshare; and b) it could end somewhat
of a standard. My take on a lot of the template stuff is that it will be
niche/proprietary unless some flavor/flavors lead to a standard.