I am working on a restaurant web portal which will send periodic emails to the registered users such as changes in menu, discounts and offers, birthday wishes etc.
Here is how I am doing it-
- I create a JSP page with the HTML formatting. This page accepts certain parameters that will customize the page.
- The MailDaemon scans the db and upon a certain trigger will make a GET request to the JSP.
- The returned JSP represents the final mail content which is then sent using the JavaMail API.
My questions are these –
- Do I really need to make a GET request? Or can I obtain the JSP result directly in my Daemon class?
- Does my approach have any drawbacks? Any better solutions (architecturally speaking)
- Any other templating solutions for the job?
javax.servlet.RequestDispatcher#includeby wrapping original response injavax.servlet.ServletResponseWrapper(in case yourMailDaemonis a servlet)