velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Rettig <>
Subject Re: Getting String object of compiled template
Date Mon, 02 Aug 2004 22:02:54 GMT
I do the exact same thing for email. It's just a couple lines of code. 

This should do it...
// import velocity classes

        VelocityEngine eng = new VelocityEngine();
        //setup engine
        StringWriter writer = new StringWriter();
        VelocityContext context = new VelocityContext();
        // populate context
        eng.mergeTemplate("myTemplate.vm", context, writer);
        String result = writer.toString();

On Mon, 2 Aug 2004 16:35:48 -0500, Bolinger, Gregg D
<> wrote:
> I have done this before and for the life of me can't find the code nor
> can I figure out how I found out.  I have a template that I would like
> to use for Emailing.  To work with the JavaMail API I just need to get a
> String back of the template merged with the data.  Can someone tell me
> how to do this?  I searched the archives but didn't come up with
> anything.
> Thanks.
> Gregg

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

View raw message