Which Java template system should I use to create email?

I have a website that uses JSP as its browsing technology (and Spring MVC below). Unfortunately, JSP is just painful to use for anything that is not related to an HTTP session. I would like to be able to send my users emails from time to time, and I want to use JSP-JSP to display email content. Technologies that I know about include:

  • JSP I think it can make you work on such things. In the worst case scenario, I could request a page from my own web server and display it in an email (ugh!)
  • Velocity - I heard good things about it, and I lean towards him.
  • StringTemplate - looks good, but I'm worried that no new releases came out in a year.

Is there a preferred technology for patterns in the Java system? Will people generally recommend speed? Is there a good way to use JSP for more general tasks?

+4
source share
3 answers

You have to go with Velocity. It is easy to learn and has a low level of dependency and implementation, especially when using Spring.

But if this is just one use case, you should stick with String and if you don't have time for experimentation;)

+5
source

I used Freemarker for email templates and it worked great and was easy to use.

+6
source

I used StringTemplate several times to send emails. It is simple and extremely easy to integrate.

The simplicity of a StringTemplate makes it easy to replace different parts of a message, such as a subject. Not sure how to do this with Velocity.

I would not worry about the frequency of release - perhaps it is good enough and does not need active development.

+1
source

All Articles