I have an app that has many emails when the form is submit or when the request is approved etc.
How can I make the email sending optional.
Example once say the form is submit before the success or the next page is loaded , a pop up is given to the user (Do you wish to send this so and so emails ok and cancel)
If ok is clicked send the email else cancel the email generation and move on to the next page.
Lets say if the user clicks the OK button it will return true and then you might forward the request to next page.
So read the return value from the pop up window and if the return value is true then add new paratmer to the request lets say sendMail then in the next page check for this parameter value if it has some value then send email if it is null then do not send email.
If my current workflow is request form -> controller servlet -> Servlet to process the logic (sets request with information required to send the email) -> success page.
And is this a good idea if I have to implement ? is there any library , any alternative i can use?
i believe request form is a jsp page lets say A.jsp
then in A.jsp
function confirmation() {
var answer = confirm("Ok to submit the form?")
if (answer){
set the request parameter here.
<%request.setAttribute("sendMail","Yes"); %>
submit the form.
}
}
Siva Masilamani wrote:
function confirmation() {
var answer = confirm("Ok to submit the form?")
if (answer){
set the request parameter here.
<%request.setAttribute("sendMail","Yes"); %>
submit the form.
}
}
That won't even come close to working. The attribute will be set on the server long before any JavaScript is executed in the browser.