Using jsp engine within a servlet for generating dynamic email messages based on jsp pages
Posted on 2003-03-25
I know. It sounds crazy.
But, I'm trying to generate email messages dynamically within a servlet and send them with inputs that I got from the servlet request.
Since my application is using JSP pages and this seperates the view from the model I thought of using the same engine for my internal use. This way users could change the email template as they wish and my application will keep on plugging in the appropriate data.
One posibility that I came up with was to use a template builder such as Apache's Velocity, but that will just introduce a new scripting language on top of JSP for my users.
I thought of creating my own request and response that will buffer the response, but I'm not sure how to invoke the jsp engine from within my servlet. I will also need the control back from the engine in order to email the message and send response back to my web client.
I'm running on top of an Apache Tomcat v4.1.18, but would rather find a solution which is cross servlet/JSP engines. I will need it to run as part of a war file that will also be installed on a BEA WebLogic and IBM WebSphere.
Thanks for the help,