You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by David Duddleston <da...@i2a.com> on 2001/05/11 09:58:14 UTC

Syntax Help - how do I do this - days[i%days.length]

I love Velocity and have figured out how to do most of the things I need to
do, but I'm stuck on a few things... here is one of them


I can't figure out a way to do this in Velocity

Here is the JSP code.

<%
    String[] days = {"Mon", "Tue", "Wed", "Thur", "Fri"};

    for(int i = 0; i < 28; i++)
    {
       out.println(days[i%days.length];
    }
%>

    or I do this...


    for(int i = 0; i < 28; i++)
    {
       out.println(rloop(i, days));
    }

    public static String rloop(int count, String[] list)
    {
        return list[count%list.length];
    }


If I take the macro approach, this is what I have.

Of course my rloop _wannabe_ Velocity macro is not legal and won't parse.
I'm so lost in vmmacro land.

#macro ( rloop $count $list)
     #set( $result = $list[$count%$list.length] )
     $result
#end

#set( $days = ["Mon", "Tue", "Wed", "Thur", "Fri"] )

#foreach ( $i in [0..15] )
    #rloop($i $days)
#end



-david



Re: Simple questions

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Jorge De Flon wrote:
> 
> Hello,
> 
> I Apologize if my questions are too simple, but i have not found the answers
> in the users guide (maybe i overlooked them)
> 1) Do you need apache to run velocity? can it run in other webserver (IIS?
> netscape?)

You don't need the Apache webserver, but will need a reasonably good
servlet container.

> 2) Do you need a servlet container?

If you wish to use Velocity for web work, yes, that would be the best
way.

Take a look at Tomcat  http://jakarta.apache.org/tomcat/

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
"still climbing up to the shoulders..."

Re: Simple questions

Posted by Jon Stevens <jo...@latchkey.com>.
on 5/11/01 4:06 PM, "Jorge De Flon" <ja...@yahoo.com> wrote:

> thank you for your quick and helpful reply.
> 
> I am begining to use it, and I am trying to use it as a java-PHP, that is,
> a simple scripting language for apache AND IIS.
> later (when i learn it well enough ), I want to use servlets and even EJB in
> the business side.
> is that possible?
> do i need tomcat? or only a webserver?
> 
> thank you again.

http://www.oreilly.com/catalog/jservlet2/

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


RE: Simple questions

Posted by Jorge De Flon <ja...@yahoo.com>.
thank you for your quick and helpful reply.

I am begining to use it, and I am trying to use it as a java-PHP, that is,
a simple scripting language for apache AND IIS.
later (when i learn it well enough ), I want to use servlets and even EJB in
the business side.
is that possible?
do i need tomcat? or only a webserver?


thank you again.


----- Original Message -----
From: Jon Stevens <jo...@latchkey.com>
To: velocity-user <ve...@jakarta.apache.org>
Sent: Friday, May 11, 2001 5:47 PM
Subject: Re: Simple questions


> on 5/11/01 3:37 PM, "Jorge De Flon" <ja...@yahoo.com> wrote:
>
> > Hello,
> >
> > I Apologize if my questions are too simple,
>
> Well, it would be helpful if they were more specific rather than simple
> since simple is relative.
>
> > but i have not found the answers
> > in the users guide (maybe i overlooked them)
> > 1) Do you need apache to run velocity? can it run in other webserver
(IIS?
> > netscape?)
>
> That is two different questions.
>
> #1a. No.
> #1b. Yes.
>
> > 2) Do you need a servlet container?
>
> The answer is that it depends on what you are trying to do.
>
> -jon
>
> --
> If you come from a Perl or PHP background, JSP is a way to take
> your pain to new levels. --Anonymous
> <http://jakarta.apache.org/velocity/ymtd/ymtd.html>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Re: Simple questions

Posted by Jon Stevens <jo...@latchkey.com>.
on 5/11/01 3:37 PM, "Jorge De Flon" <ja...@yahoo.com> wrote:

> Hello,
> 
> I Apologize if my questions are too simple,

Well, it would be helpful if they were more specific rather than simple
since simple is relative.

> but i have not found the answers
> in the users guide (maybe i overlooked them)
> 1) Do you need apache to run velocity? can it run in other webserver (IIS?
> netscape?)

That is two different questions.

#1a. No.
#1b. Yes.

> 2) Do you need a servlet container?

The answer is that it depends on what you are trying to do.

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


Simple questions

Posted by Jorge De Flon <ja...@yahoo.com>.
Hello,

I Apologize if my questions are too simple, but i have not found the answers
in the users guide (maybe i overlooked them)
1) Do you need apache to run velocity? can it run in other webserver (IIS?
netscape?)
2) Do you need a servlet container?

Any help or commentary is wellcome,
Thanks in advance.






_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Re: I'm having fun... now on to Caching

Posted by Jon Stevens <jo...@latchkey.com>.
on 5/11/01 9:23 PM, "David Duddleston" <da...@i2a.com> wrote:

> Here is a scenario. I have a site where the content does not change alot,
> but it takes a huge load. Each page on the site consists of several included
> templates. Some of the included templates in that page will change alot and
> some don't change at all. Some of them are headers that are unique to the
> visitor and are used on almost every page on the site, but can be cached per
> session as once it is created it will remain unchanged for the whole
> session.

Ok.

> #parse(header.vm) ##cache per session... customized for user.
> #parse(current_time.vm) ##no cache... changes everytime.
> #parse(menu_home.vm) ##long term cache... rarely changes.
> #parse(home.vm) ##medium term cache... changes once a day.
> #parse(footer) ##long term cache... rarely changes.

Right, but this can't really be cached. There is no completely static
content here. The parsing of the template is cached, but caching the data in
the templates doesn't make sense because the templates are not static data.

If you have static non-parsed data, then use #include.

> So in short. There is page level caching which can be handled by the
> application framework and component level caching which may need to be
> intergrated into Velocity to work.

I don't think that is possible because there is no way to know what is
static and what isn't. Webmacro has a feature to "mark" what is static and
what isn't, but then you are completely breaking the MVC pattern and I would
be against adding something like that to Velocity as a standard part of it
because I don't think there is a lot of overall gain in it. Velocity builds
a proper AST so it understands which parts of the page are static TEXT and
which parts are other types of nodes and deals with them properly.

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


RE: I'm having fun... now on to Caching

Posted by David Duddleston <da...@i2a.com>.
> I am interested to know what problem you are trying to solve where this
> is important.

Here is a scenario. I have a site where the content does not change alot,
but it takes a huge load. Each page on the site consists of several included
templates. Some of the included templates in that page will change alot and
some don't change at all. Some of them are headers that are unique to the
visitor and are used on almost every page on the site, but can be cached per
session as once it is created it will remain unchanged for the whole
session.

> The big problem, and what I think the entire problem will boil down to,
> is how the objects in the context change.

Right, this can be a hastle, but at least as the application developer, I
usualy know when and how data is changed and can invalidate that data given
that I have an interface that supports this. I can easily work around
Velocity to implement this part.

> It's an important thing, but I am not convinced it's a Velocity issue -
> it's more in the domain of a framework, I think.

The trick for this senario is to issolate and control individual templates.
If I have a template that includes 5 templates. I could get the results of
the whole page being rendered, but have no control of the included
templates.

## Velocity Script for Home page /index.vm

#parse(header.vm) ##cache per session... customized for user.
#parse(current_time.vm) ##no cache... changes everytime.
#parse(menu_home.vm) ##long term cache... rarely changes.
#parse(home.vm) ##medium term cache... changes once a day.
#parse(footer) ##long term cache... rarely changes.

In this case, the page needs to be rendered everytime, but only a few parts
of it need actual rendering.

This is just one type of caching. To implement this type of caching, each
template may need to have some caching properties and maybe a listener. I
think to have this sort of caching, it may need to be built into Velocity or
Velocity will need to be extened by the user which may be easy or difficult.

The above is just one way of caching based on a particular need. There are
other needs like the ability to cache renderings against the same template
but with differnt data in the context. An example would be how a message
forum would us a single Template to generate lots of HTML pages that
represent different messages. Each message uses a different dataset. Once
the output for message 1 is created, it can be cached and used the next time
it is requested. This kind of caching can be handled by the framework, if it
only entails page level caching. But if it includes the above example of
component or sub template caching, then you have some issue to work out.

So in short. There is page level caching which can be handled by the
application framework and component level caching which may need to be
intergrated into Velocity to work.

-david



Re: I'm having fun... now on to Caching

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
David Duddleston wrote:
> 
> In short... renderings. The caching could be built on top of Velocity and
> managed by the application using Velocity and not Velocity itself, but it
> might be possible to build some of this into Velocity.

I am interested to know what problem you are trying to solve where this
is important.

We have discussed this on and off for a while.  The problem always boils
down to not whether the context changed - that's easy - but if the data
that would be returned by the data objects in the context has changed.

If you know that, I think that it's a straightforward problem, for the
most part - given some parameterized request, you can simply store a
bytestream of the rendered template.

The catch, I think, will be the parameterization of the request, and
knowing if your data has changed.  I think that both of those prevent a
general solution.

> 
> I don't know the internals of Velocity, so I could be way off on what is
> feasible. I'm just thinking out load right now and wondered if anyone else
> has thought about ways to implement a rendered template/context cache. I
> would think there could be a way to determine if a context and the data it
> contains is still valid and that the Template has not changed since the last
> render against that context. 

It's pretty easy to know if the template has changed - as a matter of
fact, the File and Jar loaders handle this already.  As for the context,
you can easily implement your own context that will tell you last time
put() was called.

The big problem, and what I think the entire problem will boil down to,
is how the objects in the context change.

> If all is still valid and up-to-date, then
> Velocity would use a cached version of the rendering instead of rerendering
> it. The concept seems simple, but I realize there are some sticky issues to
> be worked out and it could be difficult. One sticky issue is with
> VelocityServlet or using Velocity in a Servlet enviroment. Normaly a context
> is created and the request and response objects are added along with any
> additional data the application provides. To determine if a cached version
> of the rendering could be used, a few checks would need to be made... has
> the Template or any child Templates/Macros been changed... is the Template
> using any data in the request or response objects, since these change on
> every request... is there a change to the data that would be placed into the
> context to be rendered.
> 
> If this is beyond the scope of Velocity, a stupid idea, not feasible, totaly
> retarded, then I will drop the subject ;-)
> 

It's an important thing, but I am not convinced it's a Velocity issue -
it's more in the domain of a framework, I think.

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
"still climbing up to the shoulders..."

RE: I'm having fun... now on to Caching

Posted by David Duddleston <da...@i2a.com>.
In short... renderings. The caching could be built on top of Velocity and
managed by the application using Velocity and not Velocity itself, but it
might be possible to build some of this into Velocity.

I don't know the internals of Velocity, so I could be way off on what is
feasible. I'm just thinking out load right now and wondered if anyone else
has thought about ways to implement a rendered template/context cache. I
would think there could be a way to determine if a context and the data it
contains is still valid and that the Template has not changed since the last
render against that context. If all is still valid and up-to-date, then
Velocity would use a cached version of the rendering instead of rerendering
it. The concept seems simple, but I realize there are some sticky issues to
be worked out and it could be difficult. One sticky issue is with
VelocityServlet or using Velocity in a Servlet enviroment. Normaly a context
is created and the request and response objects are added along with any
additional data the application provides. To determine if a cached version
of the rendering could be used, a few checks would need to be made... has
the Template or any child Templates/Macros been changed... is the Template
using any data in the request or response objects, since these change on
every request... is there a change to the data that would be placed into the
context to be rendered.

If this is beyond the scope of Velocity, a stupid idea, not feasible, totaly
retarded, then I will drop the subject ;-)

-david

> -----Original Message-----
> From: gmj@mta6.srv.hcvlny.cv.net [mailto:gmj@mta6.srv.hcvlny.cv.net]On
> Behalf Of Geir Magnusson Jr.
> Sent: Friday, May 11, 2001 4:27 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: I'm having fun... now on to Caching
>
>
> David Duddleston wrote:
> >
> > First off. Geir, thank you so much for the quick and
> informative responses.
> >
> > I'm really getting the hang of Velocity now (thanks to some help) and my
> > next step would be to try and take advantage of caching some
> way... I'm such
> > a huge caching fan! I know caching is not currently implemented
> in Velocity
> > (well there is Template caching), but I remember reading that
> it is planned
> > and that Geir had some ideas about some possible approaches. I
> looked around
> > (the latest CVS version) and could not find any information other than a
> > brief mention in the todo.
>
> Caching what?
>
> --
> Geir Magnusson Jr.                           geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> "still climbing up to the shoulders..."


Re: I'm having fun... now on to Caching

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
David Duddleston wrote:
> 
> First off. Geir, thank you so much for the quick and informative responses.
> 
> I'm really getting the hang of Velocity now (thanks to some help) and my
> next step would be to try and take advantage of caching some way... I'm such
> a huge caching fan! I know caching is not currently implemented in Velocity
> (well there is Template caching), but I remember reading that it is planned
> and that Geir had some ideas about some possible approaches. I looked around
> (the latest CVS version) and could not find any information other than a
> brief mention in the todo.

Caching what?

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
"still climbing up to the shoulders..."

I'm having fun... now on to Caching

Posted by David Duddleston <da...@i2a.com>.
First off. Geir, thank you so much for the quick and informative responses.

I'm really getting the hang of Velocity now (thanks to some help) and my
next step would be to try and take advantage of caching some way... I'm such
a huge caching fan! I know caching is not currently implemented in Velocity
(well there is Template caching), but I remember reading that it is planned
and that Geir had some ideas about some possible approaches. I looked around
(the latest CVS version) and could not find any information other than a
brief mention in the todo.

Thanks.

-david


Re: Syntax Help - how do I do this - days[i%days.length]

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
David Duddleston wrote:
> 
> I love Velocity and have figured out how to do most of the things I need to
> do, but I'm stuck on a few things... here is one of them
> 
> I can't figure out a way to do this in Velocity
> 
> Here is the JSP code.
> 
> <%
>     String[] days = {"Mon", "Tue", "Wed", "Thur", "Fri"};
> 
>     for(int i = 0; i < 28; i++)
>     {
>        out.println(days[i%days.length];
>     }
> %>

This is one of those examples where JSP outshines Velocity because of
the complicated code you must generate in Velocity's limited,
restrictive template language.

#set($days = ["Mon", "Tue", "Wed", "Thur", "Fri"] )

#foreach( $day in [0..27] )
   #set($which = $day % $days.size())
   $days.get($which)
#end

;->

The 'trick' to know is that the range operator and array operator
produce nice ArrayList objects, so they can do useful things for you.

>     or I do this...
> 
>     for(int i = 0; i < 28; i++)
>     {
>        out.println(rloop(i, days));
>     }
> 
>     public static String rloop(int count, String[] list)
>     {
>         return list[count%list.length];
>     }
> 
> If I take the macro approach, this is what I have.
> 
> Of course my rloop _wannabe_ Velocity macro is not legal and won't parse.
> I'm so lost in vmmacro land.
> 
> #macro ( rloop $count $list)
>      #set( $result = $list[$count%$list.length] )
>      $result
> #end
> 
> #set( $days = ["Mon", "Tue", "Wed", "Thur", "Fri"] )
> 
> #foreach ( $i in [0..15] )
>     #rloop($i $days)
> #end

You were on exactly the right track.  The only problems were to note
that unlike C, C++, Java, etc you can't drop a modulus anywhere - we
restrict them to proper expressions : #if(<expr>) and #set( <expr> ) and
that we don't support array access like [] because of various and sundry
safety concerns.

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
"still climbing up to the shoulders..."

Re: Unhelpful messages on syntax errors

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Magnús Þór Torfason wrote:
> 
> I've been using Velocity in a Turbine webapp, but decided that I would have
> to check out the standalone setup, to get a hang of how Velocity is used
> without Turbine.
> 
> So, I setup the forumdemo (very neat!).
> 
> What strikes me is that if I modify the templates, so that there is a syntax
> error, I get the following error:
> 
> VelocityServlet : Error processing the template
> java.lang.Exception: Cannot find the template!
> 
> This happens in a completely standard drop-in installation of forumdemo, and
> when the syntax error is fixed, all is well again.
> 
> It is just that for first-timers, not knowing if you have a configuration
> error, or simply a bug in the template, can be pretty frustrating.
> 
> Any thoughts?

It helps us separate the wheat from the chaff...  I wanted to make it
"Not a typewriter", but no one would let me.

Seriously, I think it's pretty simple - we forgot to update forum demo
when we added groovy application exceptions. "in the beginning" we
didn't have good informative exceptions to propogate to the app layer
when something happened in getting or merging the template.

Now there is a set of application exceptions, the one you would want is
ParseErrorException.  I will take a look and update, or if  you have a
patch, so much the better :)

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
"still climbing up to the shoulders..."

Re: Unhelpful messages on syntax errors

Posted by Jon Stevens <jo...@latchkey.com>.
on 5/11/01 6:33 AM, "Magnús Þór Torfason" <ma...@handtolvur.is> wrote:

> In my defence, I took a look at providing a patch but I'm really a total
> novice in the workings of Velocity, so I chickened out.

Never ever be afraid to provide a patch.

At the same time, never ever get so caught up in things that you can't take
someone telling you that your patch needs work and suggesting ways to fix
it.

:-)

We are all learning here. That is why we get so much work done.

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


RE: Unhelpful messages on syntax errors

Posted by Magnús Þór Torfason <ma...@handtolvur.is>.
Geir, you spoil us rotten :)

In my defence, I took a look at providing a patch but I'm really a total
novice in the workings of Velocity, so I chickened out.

Thanks for amazingly quick responses to this and other velocity issues!

Cheers,

Magnus

> -----Original Message-----
> From: gmj@mta6.srv.hcvlny.cv.net [mailto:gmj@mta6.srv.hcvlny.cv.net]On
> Behalf Of Geir Magnusson Jr.
> Sent: 11. maí 2001 13:33
> To: velocity-user@jakarta.apache.org
> Subject: Re: Unhelpful messages on syntax errors
>
>
> Magnús Þór Torfason wrote:
> >
> > I've been using Velocity in a Turbine webapp, but decided that
> I would have
> > to check out the standalone setup, to get a hang of how Velocity is used
> > without Turbine.
> >
> > So, I setup the forumdemo (very neat!).
> >
> > What strikes me is that if I modify the templates, so that
> there is a syntax
> > error, I get the following error:
> >
> > VelocityServlet : Error processing the template
> > java.lang.Exception: Cannot find the template!
> >
> > This happens in a completely standard drop-in installation of
> forumdemo, and
> > when the syntax error is fixed, all is well again.
> >
> > It is just that for first-timers, not knowing if you have a
> configuration
> > error, or simply a bug in the template, can be pretty frustrating.
> >
> > Any thoughts?
>
> Fixed. I added the exceptions, and changed things so the error message
> (parsing, resource not found...) go to both console as well as
> browser...
>
> in current CVS
>
> geir
>
> --
> Geir Magnusson Jr.                           geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> "still climbing up to the shoulders..."


Re: Unhelpful messages on syntax errors

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Magnús Þór Torfason wrote:
> 
> I've been using Velocity in a Turbine webapp, but decided that I would have
> to check out the standalone setup, to get a hang of how Velocity is used
> without Turbine.
> 
> So, I setup the forumdemo (very neat!).
> 
> What strikes me is that if I modify the templates, so that there is a syntax
> error, I get the following error:
> 
> VelocityServlet : Error processing the template
> java.lang.Exception: Cannot find the template!
> 
> This happens in a completely standard drop-in installation of forumdemo, and
> when the syntax error is fixed, all is well again.
> 
> It is just that for first-timers, not knowing if you have a configuration
> error, or simply a bug in the template, can be pretty frustrating.
> 
> Any thoughts?

Fixed. I added the exceptions, and changed things so the error message
(parsing, resource not found...) go to both console as well as
browser...

in current CVS

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
"still climbing up to the shoulders..."

Unhelpful messages on syntax errors

Posted by Magnús Þór Torfason <ma...@handtolvur.is>.
I've been using Velocity in a Turbine webapp, but decided that I would have
to check out the standalone setup, to get a hang of how Velocity is used
without Turbine.

So, I setup the forumdemo (very neat!).

What strikes me is that if I modify the templates, so that there is a syntax
error, I get the following error:

VelocityServlet : Error processing the template
java.lang.Exception: Cannot find the template!

This happens in a completely standard drop-in installation of forumdemo, and
when the syntax error is fixed, all is well again.

It is just that for first-timers, not knowing if you have a configuration
error, or simply a bug in the template, can be pretty frustrating.

Any thoughts?

Magnus


Re: Syntax Help - how do I do this - days[i%days.length]

Posted by Jon Stevens <jo...@latchkey.com>.
on 5/11/01 12:58 AM, "David Duddleston" <da...@i2a.com> wrote:

> 
> I love Velocity and have figured out how to do most of the things I need to
> do, but I'm stuck on a few things... here is one of them
> 
> 
> I can't figure out a way to do this in Velocity
> 
> Here is the JSP code.
> 
> <%
>   String[] days = {"Mon", "Tue", "Wed", "Thur", "Fri"};
> 
>   for(int i = 0; i < 28; i++)
>   {
>      out.println(days[i%days.length];
>   }
> %>
> 
>   or I do this...
> 
> 
>   for(int i = 0; i < 28; i++)
>   {
>      out.println(rloop(i, days));
>   }
> 
>   public static String rloop(int count, String[] list)
>   {
>       return list[count%list.length];
>   }

Embedding Java code in your JSP page? Tisk Tisk Tisk ...well at least you
found Velocity... :-)

> If I take the macro approach, this is what I have.
> 
> Of course my rloop _wannabe_ Velocity macro is not legal and won't parse.
> I'm so lost in vmmacro land.
> 
> #macro ( rloop $count $list)
>    #set( $result = $list[$count%$list.length] )
>    $result
> #end
> 
> #set( $days = ["Mon", "Tue", "Wed", "Thur", "Fri"] )
> 
> #foreach ( $i in [0..15] )
>   #rloop($i $days)
> #end

$list is an ArrayList object...so treat it as that...

$list.get($count % $list.length)

Now, I don't think you can embed math logic into the () so you may need to
do this:

#set ( $foo = $count % $list.length )
$list.get($foo)

If that doesn't work, then you need to define an object and put it into the
context to do that for you...

#set ( $foo = $math.mod ( $count, $list.length ) )
$list.get($foo)

I hope that helps.

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>