For this, I think that you basically need a Tomcat server (or equivalent), and when creating the email, send a request to the server to call your JSP, which will then send back the email content (or the HTML part of the email) as an answer. However, it is not very elegant.
You will probably be better off with a separate template system. Here is an interesting answer from the corresponding question.
(shameless plugin: I like Clearsilver as a template system if you are on UNIX / Linux)
David z
source share