Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

running background process  RSS feed

 
Sundeep Malali
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use the message driven to implement such function.
 
Michael Bronshteyn
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doesn't the Servlet API spec prohibit starting Threads? Not that I imagine it would cause much harm...
 
Guy Allard
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at the 2.4 specs: both of the above 'requirements' are now 'recommendations'.
G.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!