Velocity Variable Scope and mergeTemplates()
How variables in one template managed to bleed into another unrelated template.
Author: M Butcher
Date: 2008-01-10 12:47:46 -0500
While working on an Apache Velocity website, I noticed an interesting behavior: Velocity was re-using variables across requests. A variable set during request A was still available in request B -- even if I re-created the context, the engine, and all.
After reading the code, scouring the bug database for Velocity, reading the Wiki, and reading many, many mailing list posts, I finally found the problem: Velocity uses your Map objects to cache its variables. And a static Map can turn into a global namespace.
I posted a detailed blog on this at the Rhizome/Sinciput site.
|