Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Making a servlet wait for a response?

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to make a servlet sit and wait, while another servlet is performing some other tasks?
(My idea of how it might work...Although I'm probable way off)
When the second servlet is finished its tasks, it makes a call to the first servlet and tells it to wake.
Im not sure if it can be done using threads?
------------------
God put me on this planet to accomplish a certain number of things. Currently I'm so far behind I�ll leave forever.
 
Vlad Patryshev
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The idea of servlets calling other servlets as if they were programs... sounds a little bit weird, does not it?
It seems like the tasks are supposed to be performed by beans, not by servlets. If it is a TASK, why not move it from servlets to beans?
 
Manohar Karamballi
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I Think it is possible but i did n't tried.
Test the following piece of code..
Servlet1
service(request, response)
{
////other code

//call servlet2 here using Request dispatrcher
getServletConfig().getServletContext().getRequestDispatcher("absolute URL for servlet2").include(request,response);

///Remaining code
}
Let me know whether it works or not.....
/// Everything is possible if there are API's :-))
Rgds
Manohar
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for you help guys. I eventually worked around the problem.
------------------
God put me on this planet to accomplish a certain number of things. Currently I'm so far behind I�ll live forever.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic