Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Java templating system should I use to generate emails?

I have a website that uses JSP as its view technology (and Spring MVC underneath). Unfortunately, JSP is just a pain to use for anything that doesn't involve an HTTP session. I would like to be able to occasionally send my users some email, and I want to use something JSP-like to render the email's contents. Technologies I'm aware of include:

  • JSP -- It can be forced to work for this sort of thing, I think. Very worst case, I could request the page from my own webserver and render that into an email (ugh!)
  • Velocity -- I've heard good things about this one, and am leaning towards it.
  • StringTemplate -- Looks okay, but I'm worried that no new releases have come out in a year.

Is there a preferred technology for templating in a Java system? Would folks generally recommend Velocity? Is there a good way to use JSP for more generic tasks?

like image 773
Brandon Yarbrough Avatar asked Jun 29 '09 23:06

Brandon Yarbrough


People also ask

Which is better Thymeleaf or FreeMarker?

In the pursuit of comparison between FreeMarker , Thymeleaf, Groovy and Mustache, FreeMarker has the upper hand in performance. However, Thymeleaf wins the battle overall.


2 Answers

I used Freemarker a lot for e-mail templating and it worked great and was easy to use.

like image 99
yalestar Avatar answered Sep 21 '22 19:09

yalestar


You should go with Velocity. It's easy to learn and has a low dependency and implementation footprint, especially when using Spring.

But, if it's just one Use Case, you should stick with the String and unless you have no time for experiments ;)

like image 45
cafebabe Avatar answered Sep 20 '22 19:09

cafebabe