Velocity

Velocity is a Java-based template engine. It permits web page designers to reference methods defined in Java code.

Velocity

Velocity

     

Apache Velocity is template engine developed by apache foundation for the development of views using the templates. Velocity provides many features for easy development of view using the templates.

Developers can use this engine with any type of Java programs. Event a desktop application developed in Java can use the Velocity templates for generating formatted output.

In web applications it is mostly used to generate the view part of the web applications. In this tutorial you will learn Velocity template with the help of many examples.

  1. What is Velocity?
    Velocity is a Java-based template engine. It permits web page designers to reference methods defined in Java code. At the Jakarta Velocity Project Website, where you can download the freely available source code, a thriving and growing community of users is ready to answer questions and offer solutions to common templating problems.
     
  2. Call class methods
    This Example shows you how to call class method in velocity template. 
     
  3. Calculation Example
    This Example shows, how to calculate using velocity. This code displays the product name and their price with the total amount of all product.
      
  4. Reference Class Properties
    This Example shows you how to use class properties in your velocity template.
      
  5. XML handling in a template using Velocity
    This Example shows you how to use XML file in a velocity template and also shows that use of  macro to wrap HTML tag in velocity  template.
     
  6. Show output as a xml file using Velocity
    This Example shows you how to show output as a xml file in velocity.
     
  7. Define and use Macro in Velocity
    This Example shows you how to define and use macro in velocity  template and also shows how to use Iterator in velocity  template.
     
  8. Show content of .vm file as output using Velocity
    This Example shows you how to display content of .vm file using velocity and also shows how to use Iterator in velocity  template.
      
  9. How to pass java.util.Properties in properties
    This Example shows you how to use java.util.Properties to in velocity.
      
  10. How to use Map in velocity
    This Example shows you how to use map in velocity.
      
  11. Velocity Macro with Parameters
    This Example shows you how to use macro with parameters in velocity  template.
      
  12. Use macro to wrap HTML tags in velocity
    This Example shows you how to use macro to wrap HTML tag in velocity  template. 
      
  13. How to use foreach loop in velocity
    This Example shows you how to use foreach loop in velocity  template.
      
  14. How to use List in velocity
    This Example shows you how to use List in velocity.
      
  15. Velocity Iterator Tool Example
    This Example shows you how to use Iterator in velocity  template.
     
  16. Include template file in another template file
    This Example shows you how to include another template file.
      
  17. Velocity with External Properties
    This Example shows you how to use Velocity with External Properties.
      
  18. Date Tool Example
    This Example shows you how to display date and time velocity.
     
  19. Use if and elseif statements in velocity
    This Example shows you how to use If and elseif in velocity.
     
  20. Use if else and end statements in velocity
    This Example shows you how to Use if in velocity.
      
  21. Use if in velocity
    This example shows you how to use if statement in velocity.
      
  22. How to define variable in Velocity
    This Example shows you how to define a variable in velocity.
      
  23. How to set a variable value using velocity
    This Example shows you how to set variable value using velocity.
      
  24. Foreach loop with negative index in velocity
    This Example shows you how to use foreach loop with negative index in velocity.
      
  25. Use Velocity to generate HTML document
    This Example shows you how to generate HTML document using velocity.
      
  26. Data Type: String
    This Example shows you how to use string data type in velocity.
      
  27. Data Type: number
    This Example shows you how to use number data type in velocity.
      
  28. Data Type: bool
    This Example shows you how to use bool datatype in velocity.
      
  29. How to use dollar sign in velocity
    This Example shows you how to use dollar sign in velocity.