Maybe this will help you  This way I always test if variable is not null

The #if directive in Velocity allows for text to be included when the web page is generated, on the conditional that the if statement is true. For example:

#if( $foo )

The variable $foo is evaluated to determine whether it is true, which will happen under one of two circumstances: (i) $foo is a boolean (true/false) which has a true value, or (ii) the value is not null. Remember that the Velocity context only contains Objects, so when we say 'boolean', it will be represented as a Boolean (the class). This is true even for methods that return boolean - the introspection infrastructure will return a Boolean of the same logical value.


2009/7/28 Captain Cid <>

I have a template containing some variables to be rendered from context.
Is there way by which i can know if all the variables are present in the
context, otherwise throw an error.
View this message in context:
Sent from the Velocity - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail: