my dog learned polymorphism
The moose likes Threads and Synchronization and the fly likes running background process Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "running background process" Watch "running background process" New topic
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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: running background process
 
Similar Threads
Thread from servlet ?
Passing data from servlet/jsp
use temporary queue to get return value from onMessage() and how to pick it up
listen to events from a servlet in an embedded tomcat
how to send email from servlet program