Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Open Source Projects
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Other Open Source Projects
velocity in multithread environment
Rajarajan Ganesan
Greenhorn
Posts: 1
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
In my web app (
jsp
,
Servlet
and Business class) I call a instance method to get email content (using velocity template) from servlet.
below is snippet of instance method
private void translate() throws Exception { Velocity.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); Velocity.init(); VelocityContext context = new VelocityContext(); context.put("statusList", mJobStatusChangedList); context.put("now", new java.text.SimpleDateFormat( "MM/DD/YYYY hh:mm:ss am").format(new java.util.Date())); Template template = Velocity.getTemplate(templateFile); StringWriter strWriter = new StringWriter(); if (template != null) { template.merge(context, strWriter); message = strWriter.toString(); } }
Can any one confirm my approach is correct (Of course my program is working correctly, my concern is best practice).
Martijn Verburg
author
Posts: 3285
13
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Rajarajan Ganesan and welcome to Javaranch!
I'm _not_ a velocity developer, but what you have there seems reasonable - hopefully a Velocity developer can chime in.
Cheers, Martijn,
Twitter
.
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Regarding velocity template and also sending the mail using this
Velocity Templates with Servlets
Velocity Error
Issue while using Apache Velocity with servlets
Velocity Templates with Servlets
More...