tags:

views:

119

answers:

1

I am developing a small utility application emailafriend using Spring. The basic functionality is to email the current url to a friend. As of now I am using a fixed email template which I have hard coded in the class something like -

StringBuffer buf = new StringBuffer(form.getSenderName());
buf.append(" want to look at this page: ").append("\n\n<");
buf.append("http://").append(host).append(form.getPageUrl()).append("&gt;\n\n");
buf.append("Please click on the link above for more information.");
buf.append("\n\n");

But, the email templates can be changed frequently as per business. Can I utilize spring for this purpose (or any other way), so that I don't have to the Java code again and again.

A: 

I suggest using a template engine such as Freemarker for this (or Velocity, but Freemarker is better, IMO). Spring provides support for these.

skaffman
Thanks. I would appreciate if you can provide some link which describes Freemarker in detail with some example.
Saurabh
I provided a link to Freemarker, and there is plenty of documentation and examples on it.
skaffman