Saturday, October 8, 2011

Part 2: Apache Velocity - Setting up the classpath

In this article we will learn to set up the class path for Apache velocity. This will help us to understand the code example in the upcoming articles. Basically Apache velocity comes into various flavors but we will cover only velocity engine. Only 2 external jars are required to set up the required class path. These jars are 
1) velocity-1.6.2.jar
2) velocity-1.6.2-dep.jar

You can download the latest jar from this location-
http: //velocity.apache.org/download.cgi

Setting up the class path   

(Assuming that one is setting class path in Eclipse)
Step 1:
  • Make a new folder name "classpath" under your project node.
  • Copy the jars in the folder.

Step 2:
  • Add the jar files in your class path.






That's all. We are ready to experience some coding example.



Part 1- Apache Velocity - ( Introduction )

 Introduction
In simple terms – Apache velocity is open source software that can be used to generate dynamic content for email, sms etc. For example –One wants to write an application which will send the “password” or “account activation link”. Normally the content of such email is fixed only certain sections such as “Password value”, “Salvation – Mr. or Ms.” change for each email. Using apache velocity, one can use a normal text file, to define the fixed content, and dynamic data, password value, to generate the email content. The Integration of text file and dynamic data is quite fast. On top of that one can define rules within the text file. So overall one can code with in a text file. 
Example of template – 

Hi $data.get(“UserName”) 
Your password is $data.get(“password”) 

Thanks, 
Jovialjava team  

This is the text from Wiki- Apache Velocity (formerly known as Jakarta Velocity) is an open source software project directed by the Apache Software Foundation. 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).