velocity.setApplicationAttribute(SERVLET_CONTEXT_KEY, getServletContext());
velocity.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.tools.view.servlet.ServletLogger");
ExtendedProperties configuration = loadConfiguration(getServletConfig());
if (macros != null)
{
configuration.addProperty("velocimacro.library", macros.getAppRelativePath());
}
configuration.setProperty("file.resource.loader.path", getServletContext().getRealPath("/"));
velocity.setExtendedProperties(configuration);
// initialize and return velocity engine