Client and server-side templating with Velocity
By Sing Li2004-06-13
Velocity as a standalone parser
To compile the example standalone parser, use the compile.bat file in the \code\app directory of the distribution. To try out the parser, use the process.bat batch file, which contains:
set VEL_HOME=\jdk1.4\vel14rc1
java -classpath ..\classes;%VEL_HOME%\velocity-dep-1.4-rc1.jar
com.ibm.dvworks.velocity.VelocityParser %1 %2 %3
Note you must set the VEL_HOME environment variable in both compile.bat and process.bat to the directory where Velocity is installed. There are two different JAR files included with Velocity distribution: velocity-dep-???.jar (where ??? is the release number info), and velocity-???.jar. The velocity-dep-???.jar file includes all external dependencies (Jakarta common-collections, Avalon Logkit, and ORO regular expression library) and can be used immediately. If you already have some of these libraries in your classpath, you may want to use the velocity-???.jar file instead. If neither of these JAR compositions suits your needs exactly, you can easily rebuild Velocity to be just the way you need it. The Velocity distribution includes an ant script to build seven different JAR configurations for different application scenarios.
To provide a pleasant out-of-the-box experience, Velocity comes with a set of default configuration properties that are reasonable and acceptable for most applications. This frees the developer from tinkering with complex configuration options at the initial get-go and allows him or her to experiment immediately with the template engine.
Tutorial Pages:
» Client and server-side templating with Velocity
» Basic template engine operation
» Velocity contexts
» Velocity as a standalone parser
» Velocity vs. JSP technology on the server
» Deploying Velocity with Tomcat 5
» Interoperating with the Struts framework
» Conclusions
» Resources
First published by IBM developerWorks
