I need something like the example below with Apache Tomcat.
The main problem here is that we can control database persisting, but in this case we need to send the e-mail if and only if the 'transaction' completed fine.
So, if the database persisting fails, a rollback is done, and if the e-mail is not sent, again a rollback is done. Is it possible?
Begin transaction
...
doing several things...
...
persting information at the database...
...
sending e-mail
...
Commit transaction
I would like prefereable a working code or a tutorial showing how can we put it to work on Tomcat. I'm not working with Spring too, so a solution without it would be better.
Thanks in advance.