Velocity - A J2EE Developer's Dream Template Engine
I do not know any developers that have created more than a couple web applications in Java/J2EE and has not gotten frustrated by JSP. JSP sucks - on all fronts! JSP is created to decouple presentation from the program code but nobody except a programmer can handle JSP!!! It is presentation for ... programmers. Who wants it? It is ugly and limitted. Just to name a few: tag can not be an attribute of another tag, you can not easily load JSP from a JAR, JSPs need to be compiled, it is too verbose and designers HATE it, is not friendly to any WYSIWYG HTML editors.
Being frustrated, I was, naturally, looking to alternatives. First I looked at Tapestry. As far as templating goes - it is nice, and smart. But it is a full-blown MVC framework too. General rule - more functionality tools take on them, more limitting they are, because they enforce their "best practices" and that may not be the best way always. Also, my current application is, already, written in Struts and moving to or integrating with Tapestry, while possible, is going to suck.
Going around and around, I finally, decided to take a deeper look at the Jakarta Velocity. After all - I have heard too much of it and two tools I use all the time - Confluence and Jira, both use Velocity - so WTH?
Well, to put it short: writing templates with JSP and Velocity is like writing your persistence with raw JDBC or using Hibernate. YES! That\'s the kind of difference! Just like Hibernate, Velocity brings a huuuge simplification, is highly extensible, flexible and leaves you space to using alternatives, if you will so. Last but not least - it does integrate with Struts, too.
I am very, very happy. I think my journey, in search for a good templating engine has come to end and I found it - Velocity is the way to go!
I can not, possibly, blog in more detail about a rich engine like Velocity, but it\'s not necessary, either. There\'s a wonderful, brilliant book about Velocity written by Rob Harrop - Pro jakarta Velocity.This book is how I learnt Velocity and there is nothing I could add to it. Highly recommended