velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gupta, Arindam" <arindam_gu...@fanniemae.com>
Subject RE: Running Velocity in a standalone application
Date Tue, 15 Jun 2004 14:34:46 GMT
Please try something like the following. I use code like this to test
the look and feel of the pages created using the Velocity templates and
this is an extra advantage over the JSPs:

		VelocityEngine ve = new VelocityEngine();
		ve.init();
		
		Map map = new HashMap();
		map.put("Title", "Velocity generated page");
		map.put("author", "Some author");
		//....other values needed 
		VelocityContext context = new VelocityContext();
		context.put("displayValues", map);

		
		Template t = ve.getTemplate("Velocitypage.vm");
		
		StringWriter writer = new StringWriter();

		
		t.merge(context,writer);
		
		FileWriter f = new FileWriter("sample.html");
		t.merge(context,f);
		
		f.flush();
		f.close();
		
Hope this helps.

-----Original Message-----
From: Ilan Azbel [mailto:iazbel@mdio.net] 
Sent: Tuesday, June 15, 2004 10:29 AM
To: Velocity Users List
Subject: Running Velocity in a standalone application


Hello,

I would like to use velocity to produce HTML pages for me from a
standalone applications. That is, I want it to output html to disk
without it being invoked by a servlet.

Anybody know how to do this? Sample code?

Ilan


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message