• 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

Best way to create a dynamic HTML Email from a servlet

 
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A templating technology (such as Velocity) might be a good bet.
 
Devaka Cooray
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic