Apache Velocity

 

Apache Velocity is a Java-based template engine, often utilized for generating web pages using the Model-View-Controller (MVC) model. However, it has wider uses, with my particular interest being in generating JSON, HTML and Java code.

Most of the following example programs utilize Velocity template files, which use the extension "vm".

‣ Basics

‣ Dynamic Templates

Dynamic templates are created at run-time by evaluating Java strings, so don't require a separate vm file.

‣ Velocity Tools

Velocity's tools are described here.

‣ Using XML

XML is supported using the JDOM library.

‣ Using JSON

Velocity offers a JsonTool which relies on the json-simple library available at Clifton Labs. The first two examples show how to use that library to read and write JSON text without the aid of Velocity. Only the third example requires JsonTool.

‣ HTML Generation

‣ Java Generation


 

Downloads and Other Links


Dr. Andrew Davison
E-mail: ad@coe.psu.ac.th
Back to the third-party libraries page