Texantek » Core Java

Using Apache Velocity Templating Engine with Example  XML

Author Message
sagar



Joined: 16/02/2012 12:59:39
Messages: 23
Offline

Velocity is a Java-based template engine that provides a simple yet powerful template language to reference objects defined in Java code. Its aim is to ensure clean separation between the presentation tier and business tiers in a Web application (the model–view–controller design pattern).
A common implementation of the velocity engine is sending template based emails by passing certain values into it. The following example makes use of the apache velocity to pass values from a java class into the email template called"email_html.vm". This program requires the following .jar files to be included in your class path:
commons-collection.jar
commons-lang.jar
velocity.jar
log4j-1.2.8.jar

The java class is called the"EmailDemo.java" is placed inside the src folder and looks like as follows:


create another file "email_html.vm" and place it inside the same src folder and it looks like as follows:
Send a PM
 
Texantek » Core Java
Go to:   
Powered by JForum © Texantek