• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best way to create a dynamic HTML Email from a servlet

 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4499
267
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assume a scenario that you need to send a dynamic email from a web application, something like a confirmation email for the user registration. It is easy to create that email, if it is a small email having only few lines. We can create it as a String value, and then send it via JavaMail or any other api. But what if it is a large email having hundreds of html tags with a large content? What is the best way to create it?

I think it is best if we can create that email as a JSP. So we can capture the output stream of that JSP using filters, and assign it to a String variable. But do you think that it is a good practice for here?

Devaka.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A templating technology (such as Velocity) might be a good bet.
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4499
267
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Sturrock wrote:A templating technology (such as Velocity) might be a good bet.


If I tell you the truth, I didn't know about the 'templating technology' before. Thank you Paul for letting me know about it.

Devaka.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, JSP is a templating technology -- which is probably why your initial reaction was to try and use it. But I agree with Paul, using a templating engine would be more striaght-forward than trying to subvert JSP for that usage.
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4499
267
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear is right. I wondered about a 'templating technology', or something else other than JSP. Because it sounds inappropriate when JSP is subverted to that usage.

Thanks,

Devaka.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic