Get Up to Speed with Velocity

Trygve Isaacson is dumping some of his own Java code in favor of Apache Velocity, a terrific open source template publishing engine.

In the process, he found a solution to a thorny configuration problem that prevented his Web server from finding templates.

I wrote an introduction to Velocity for the December 2002 Linux Magazine. Using its own scripting language, Velocity Template Language, the class library prevents template creators from making the biggest mistake of JavaServer Pages -- mixing code used to present data with code to modify it, producing an unholy mess that's easy for everyone involved to screw up. A Velocity template only presents data; it may not contain Java statements or create objects.

Like Log4j, Velocity's so easy to learn Java programmers will be kicking themselves for not exploring it sooner.

Comments

Can you comment on how Velocity compares to Smarty? (I'm hoping that you since you're running at least parts of your site on PHP, you may know something about Smarty...)

I'm evaluating Smarty right now -- I think I may be using it on the software I'm going to release that runs this weblog.

They're similar: Both require special template languages, both require data to be assigned to a template prior to presentation, and both can be picked up quickly.

The biggest difference is one between PHP and Java. I find that a weakly typed language like PHP is harder to use.

Add a Comment

All comments are moderated before publication. These HTML tags are permitted: <p>, <b>, <i>, <a>, and <blockquote>. This site is protected by reCAPTCHA (for which the Google Privacy Policy and Terms of Service apply).