I would like to seek opinions how to make my code more 'beautiful'.
Currently, I have 2 types of Recipients for sending email - user when registered and parents when they sent the enquiry form.
So, depending on which servlet was invoked. If it is user then a mail will be sent to them and same applies to the parents'.
Now, only thing is with the code which is in my sendMail class :
How do I incorporate the method to make it known to send mail to the user or the parents' ?
The code now contains 2 types of recipients so I think this code is not 'beautiful'.
Hope someone can guide me how to improve the code....
posted 1 month ago
I have further added
But, now I wonder if the two servlets are invoked a the same time then I do not want the mail to just send out to one user, how do I make the code work to check if the 2 servlets are invoked at the same time ?
If the code is thread-safe (which means protecting access to shared mutable data) then it doesn't matter if the code is run concurrently for multiple users. Not using instance variables (at least none that change over time) in your servlet and filter would be a good start.