Arkaitz Bitorika <arkaitz@...> wrote:
> For me the best thing about Webmacro/Velocity is that the template
> language is at the same time:
> * Very simple: it has only constructs that are useful for
> presentation tasks.
> * Extendable: You can stick any object in the "context" and the
> template engine will do introspection for you.
> For example:
> #foreach ($user in $users)
> This will look for getName() and getSurname in the objects of the
> $users list. This kind of stuff is _extremely_ useful and clean.
I'm not convinced. I read those articles, and while they made some
good points I didn't feel the points made were against the general
server-page concept. I think they mostly came down to: (a) <>
characters are cause some problems, (b) server-pages can be misused by
putting to much code in them (but that's true for anything), (c) Java
is way to anal and verbose, (d) error messages are poor (which I think
is mostly an implementation problem), oh and (e) some other details I
So, I'm not sad that I haven't worked with JSP. But, relative to PHP
I'm not sure about the gain. PHP isn't a great language by any means
-- but the template languages are just going to make all the same
mistakes when they get older too. Most of the problems they have with
server pages is the JSP implementation.
What I see as the advantage of server pages is that you can
organically grow the functionality of the website, then start moving
code elsewhere as it matures or needs to be reused. And it's the same
language both places, so it's easy to move.
What really makes me cringe is stuff like:
<% String title = "The Page Title"; %>
<%@ include file="/header.jsp" %>
Your content here
<%@ include file="/footer.jsp" %>
That's not the proper organization -- first, "title" is either (a) a
global variable, or (b) passed through dynamic scope. Both of these
are bad engineering.
And anyway, is it really best for each page to say (and so verbosely)
what its header and footer should be? This is something that should
be defined more abstractly.
Lastly, this is a poor template. It doesn't allow you to define,
site-wide, any style of what goes in the content area.
The webmacro alternative they give:
#set $title = "The Page Title"
Your content here
Is entirely equivalent, except that it has nicer syntax.