| Author |
running background process
|
Sundeep Malali
Greenhorn
Joined: Aug 20, 2003
Posts: 3
|
|
I want to send email from my application. I need to only start the process of sending and return the control. Typically I will call the send mail method from a servlet. So after calling the method, I want to return back to the servlet and continue with rest of the processing. Any ideas on how to implement this.. Will Thread.setDaemon be useful here..\
|
 |
zb cong
Ranch Hand
Joined: Jan 14, 2002
Posts: 403
|
|
|
you can use the message driven to implement such function.
|
 |
Michael Bronshteyn
Ranch Hand
Joined: Mar 26, 2002
Posts: 85
|
|
|
If you want to call another thread from servlet, it makes sense for servlet not to wait and return from doPost ( or doGet ) method. The idea of the background processing in servlet is to allow servlet code to return while the background thread will continue. Jason Hunter book on "Java Servlet Programming" has a very good example on servlet background processing which you can use as example.
|
Michael
SCJP2
|
 |
David Weitzman
Ranch Hand
Joined: Jul 27, 2001
Posts: 1365
|
|
|
Doesn't the Servlet API spec prohibit starting Threads? Not that I imagine it would cause much harm...
|
 |
Guy Allard
Ranch Hand
Joined: Nov 24, 2000
Posts: 776
|
|
Been a while since I looked at the specs. A quick flash through the 2.2 specs (old I know) gives ...... Threads are not prohibited. Specs say: do not pass references to certain objects (request / response ) to other threads. Specs say: the container must ensure thread continuity across dispatch. Guy
|
 |
Guy Allard
Ranch Hand
Joined: Nov 24, 2000
Posts: 776
|
|
Looking at the 2.4 specs: both of the above 'requirements' are now 'recommendations'. G.
|
 |
 |
|
|
subject: running background process
|
|
|