Quoting Eduardo Pelegri-Llopart ([EMAIL PROTECTED]):
> The "template" systems that I am aware can be seen as very simple cases
> of JSP tags. Essentially they provide syntactic sugar for something
> like <x:templateEval "expr"/>,
> where "expr" is an easier to write syntax for a combination of getters
> on implicit objects. I have not mentioned before, but custom actions
> can create new implicit objects, with different types of lifescope.
>
> This is not to underestimate the value of simple syntax, specially when
> writing pages in a POTE (plain old text editor) like vi, or even
> (x|gnu|)emacs.
>
> I'd be interested if the characterization above is missing.
Well I'm obviously biased against JSP because I wrote a template
system (http://webmacro.org) precisely because I found JSP too limiting.
On the other hand, you get paid to be biased in favour of JSP so I
suppose we're even on that score.
Template systems have several architectural strengths lacking in JSP:
1. They are not monolithic. By this I mean that their use is driven
by a servlet, and the servlet can choose if and when to execute
a template. The same servlet may return some documents using
a template, and others using an XSL processor. In other words,
they are a tool in your toolbox, not a replacement for servlet
programming as JSP is.
2. Template systems do not require non-standard extensions to
Java, which is what JSP is. They work in any webserver with
an ordinary JSDK and Java runtime. The same cannot be said
of JSP (which emphasizes standards because it is non-standard).
3. Template systems intentionally limit what you can do inside the
template in order to enforce an MVC architecture. In JSP you can
manually adhere to MVC, but nothing forces you to. The consequence
is a constant temptation to violate your design, requiring vigilence
at every step. I think trying to do MVC design with JSP is akin to
doing OO design in C. You can do it, but why? I'm also not saying
that you can't find a way to abuse a template, just as it's possible
to violate OO design principles in Java if you try.
4. Most template systems offer you stronger ways to model your data
and interact with your data than is afforded by the JavaBeans
spec. FreeMarker, for example, has a fairly rich set of modelling
adapters. WebMacro (mine) performs class analysis that goes beyond
what JavaBeans mandates to facilitate the use of arrays, vectors,
and other common Java data structures that are difficult to access
in JSP because they are not totally bean-like.
Note that #4 means that template systems are doing far more than JSP
and thus not just syntatic sugar over some tag system. You shouldn't
push misinformation like that.
In my view the primary advantage that JSP has over templates is that it
is similar to ASP and EmbPerl, and thus is a more familiar environment
for people new to Java who have come from that background. However, I
don't necessarily think that model of programming is well suited to
Java, even though it's no doubt strategically important.
WebMacro was selected as one of the top three servlet products in 1999
by the Java Report. FreeMarker and WebMacro are probably the two most
widely used template systems.
Justin
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html