Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Velocity Vs JSTL

 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Rob,

I have read about velocity (javaranch actually had a nice article on that sometime back) and JSTL. As far as web development is concerned, with the advent of JSTL, does velocity still make sense?

thanks.
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not quite sure if it is recommended or not its usage in a web context. But I feel that for some tasks it would be more easy to use VTL instead of JSTL or developing custom tags.

./pope
 
Rob Harrop
Author
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Choosing between JSTL and Velocity really depends on the needs of your project. Certainly, you will find that out of the box JSTL provides many useful features that are not present in a vanilla Velocity install and many developers are already comfortable with with JSP tag syntax.

On the flip side of this, Velocity is much better in a multi-disciplined environment because its syntax is easier for non-developers to understand. Extending Velocity is really simple when using macros, which are all written in VTL, making it easy for designers to build reusable components as well as developers. For more power when building extensions you can build your own directives (a command that starts with a #) using Java. This mechanism gives you direct access to the underlying syntax tree built by the parser. Both of these approaches are covered in the book.

Since the book was written, a collection of useful Velocity macros has been added to Spring simplifying the creation of HTML forms and Velocity supoprt has been greatly extended in the framework.

You will also find that Velocity performs much better than the equivalent JSP code. I didn't quantify this in the book, but Rod Johnson does in his Expert One-on-One J2EE book - Velocity is twice as fast as JSP.

Of course, Velocity has many uses outside of the web, a topic which is covered extensively in my book. We use Velocity for generating mail from systems, for generating code as part of a generation framework, for generating CSV output plus a string of other uses.

Once you have tried Velocity and experienced the ease with which you can build web apps, I doubt you'll go back to JSP and JSTL.

Rob
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic