API / Apache Velocity Interview questions
How is Apache Velocity different from Apache FreeMarker?
Both are mature Java template engines with a similar goal, but they differ in scope and current activity.
| Aspect | Velocity | FreeMarker |
| Directive set | Small: #if, #foreach, #set, #macro, #parse | Larger: includes #switch, #list with else, #assign, #function, #compress, and more |
| Built-in functions | Minimal; most formatting needs a Java tool class | Rich built-ins for strings, dates, numbers (e.g. ?upper_case, ?date) |
| Null/undefined handling | Lenient by default, opt-in strict mode | Strict by default, requires explicit default-value operators like ! |
| Typical ecosystem | Struts, Turbine, code generators, legacy Spring apps | Spring Boot email/report templating, Struts 2 default view |
In practice, FreeMarker's richer built-in expression language reduces how often you need a custom Java tool class, while Velocity leans more heavily on exposing helper objects into the context to do the same work.
More Related questions...