Site Translations


Velocity is a Java-based template engine. It can be used as a standalone utility for generating source code, HTML, reports, or it can be combined with other systems to provide template services. Velocity will be tightly integrated with the Turbine web application framework. Velocity-Turbine provide a template service by which web applications may be developed according to a true MVC model.

Velocity has a myriad of potential uses -- generating SQL, PostScript, or Java source code from templates -- but web developers looking for a viable alternative to PHP and Java Server Pages (JSPs) are expected to be its principle user group.

Velocity allows web page designers to embed simple yet powerful script elements in their web pages. These script elements work in conjunction with a Context object, which is defined in Java code. A context object--essentially a hashtable that provides get and set methods for retrieving and setting objects by name within the Context --provides a "hook" from the Java code to the Velocity script elements. These script elements allow a web designer to retrieve objects from the Context and insert these into a web page as text values. The web designer has some control over looping (for each) and conditional statements (if/else).

Velocity enforces a Model-View-Controller (MVC) style of development by separating Java code from HTML template code. Unlike JSPs, Velocity does not allow Java code to be embedded in pages. Unlike PHP, Velocity does not implement features with other functions. The MVC approach is one of Velocity's great strengths, and allows for more maintainable and better-designed web pages.

Although MVC-style development can sometimes lead to longer incubation periods for web sites, particularly if the developers involved are new to MVC, this approach saves time over the long term (believe us, we have been doing this for a long time now). The MVC abstraction prevents web page designers from messing with a software engineer's Java code, and programmers from unduly influencing the look of web sites. Velocity enforces a contract that defines what roles people play in the web site development process.

Velocity uses a grammar-based parser generated by JavaCC (Java Compiler Compiler) using the JJTree extension to create an Abstract Syntax Tree.

Velocity's design concept is borrowed from WebMacro. Those involved in the Velocity project acknowledge and appreciate the development and design work that went into the WebMacro project.

Copyright © 1999-2004, The Apache Software Foundation