July 21st, 2003, 01:39 PM
Sending html email rendered from JSP
I need to send a large set of customized HTML emails, and I'd like to template the html with JSP.
Has anyone ever done this or know how I might go about it?
Basically, I want to have a servlet which is supplied some data (eg, first name, last name, email), uses a JSP page to assemble the data and email contents, and sends the JSP output as an HTML email.
Is there any easy way to do this? I'm stuck on how to render the JSP from within the servlet.
Any help or suggestion would be greatly appreciated!!!!
July 22nd, 2003, 10:44 AM
You can't "render" your jsp in your servlet, but you can make a URL connection to the jsp passing any parameters needed and then capture the response character stream and store the generated html code from the jsp into a StringBuffer from your servlet. Then use the stringBuffer to put the html code into your email as the body.
I think you might need to set a flag or something to make sure the email message renders as an html page rather than the actual html code (i.e. a mime type or something). Not sure how you would do this.