using System; using System.IO; using System.Diagnostics; using Commons.Collections; using NVelocity; using NVelocity.App; using NVelocity.Context; public partial class _Hello : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { VelocityEngine velocity = new VelocityEngine(); VelocityContext context = new VelocityContext(); StringWriter sw = new StringWriter(); try { String properties = Server.MapPath("nvelocity.properties"); velocity.Init(properties); Template template = velocity.GetTemplate("hello.vm"); context.Put("message", "NVelocity"); template.Merge(context, sw); Response.Write(sw.GetStringBuilder().ToString()); } catch( Exception ex ) { Debug.WriteLine("Exception: " + ex.Message); } } }