Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Client and server-side templating with Velocity

By Sing Li
2004-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


 | Bookmark
Related Tutorials:
» All about JAXP, Part 1
» Make Database Queries Without the Database
» Load List Values for Improved Efficiency
» 2 Ways To Implement Session Tracking
» A Simple Way to Read an XML File in Java
» Develop Aspect-Oriented Java Applications with Eclipse and AJDT