public static String writeToString(String templateName,
			VelocityContext context) throws Exception {
		StringWriter sw = null;
		String res = null;
		try {
			Template t = Velocity.getTemplate(templateName, "UTF-8");
			sw = new StringWriter();
			t.merge(context, sw);
			res = sw.getBuffer().toString();
			return res;
		} catch (Exception e) {
			throw new Exception(e);
		} finally {
			if (sw != null)
				sw.close();
		}
	}