If you want to do the processing in the background, fire off a thread to handle it asynchronously.
I see. Is it ok to have all that thread stuff in the servlet or should I use a separate class for that
what does it mean?
If you mean the code to persist that in the DB and sending the mail to the user you should move that to a separate class.
Manish Singh wrote:If you mean the code to persist that in the DB and sending the mail to the user you should move that to a separate class.
No, that's not what I meant. What you're saying is clear. I was wondering about the very code that starts a new thread like
I've never seen a thread-related code in a servlet before, thus the question.
Manish Singh wrote:
# Thread mailer = new Thread(new MailerBean(userData));
what is the use of above code ? is it placed inside the service method and its there to send the mail to the user?
Manish, you do not override the service() method. The code is from doPost() and what it does should be pretty clear - it creates a new instance of a class responsible for emails and passes it the data received from the user.