Java J2EE Portal
Enterprise Java Station
J2EE curve
Java News / Articles
Java News / Articles
Java Developer Interview Questions
Happenings @ IndicThreads.com Conference On Java Technology 2007
Continuous Integration - Agile Software Development Q & A
Processing...
Buy Java, Deals On Software Technology Store
Click here for great deals on computers, laptops, software and books
while learning velocity ... PDF Print
Written by Karthik Guru   
Feb 27, 2005 at 09:58 AM
I was looking at velocity for templating.  This is the first program that i wrote

package com.i2.template;

import org.apache.velocity.app.Velocity;
import  org.apache.velocity.VelocityContext;
import java.io.StringWriter;

public class Test{
     public static void main(String[] args){
          VeloctyContext ctx = new VelocityContext( );
          String template= " Hello World in $lang ";
          ctx.put("name","Java");

          StringWriter writer = new StringWriter( );
           Velocity.init( );
           Velocity.evaluate(ctx, writer,"",template );
           System.out.println(writer.getBuffer( ) ); // Hello World in Java
     }
}

I have been trying to learn python as well and suddenly it occured to me that I would do the following in Python.

st = " Hello World in %(lang)s"
result = st % {'lang':'Python'}
print  result  #  Hello World in Python

I realize that Velocity is more than just  variable substitution.  But statement /expression evaluation in python should'nt be too difficult either.

I wish I had a chance to execute a python project and figure what this Static Vs Dynamic typing  is all about .



User Comments
Your Name / Email Address
Comment
Spam Protection - Please enter the code in the image -

Listen to code


Add This Feed Button

Enter your Email

IndicThreads.com Conference On Java Technology, Pune, India
Java Expert Interviews
Anil Saldhana JBoss
JBoss is light years ahead of other open source application servers
GuillaumeLaforgeGroovy
Groovy bridges the scripting and the enterprise Java worlds
ChristopherDuncan
Programmers lose because they are unwilling to learn any skill beyond the technical
Processing...
Go to top of page  Home |
SiteMap

Copyright 2004 to 2008 Rightrix Solutions. All rights reserved. All product names are trademarks of their respective companies. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Rightrix Solutions and IndicThreads.com are independent of Sun Microsystems, Inc.

Views expressed at IndicThreads.com reflect the views of the authors alone, and do not necessarily reflect those of IndicThreads.com. IndicThreads.com and it's authors are not responsible for reader comments and opinions.

Enterprise Java J2EE JEE Portal >> IndicThreads.com