File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Making a servlet wait for a response? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Making a servlet wait for a response?" Watch "Making a servlet wait for a response?" New topic
Author

Making a servlet wait for a response?

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Jun 30, 2001
Posts: 61
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?


Thanks,<br />Vlad
Manohar Karamballi
Ranch Hand

Joined: Jul 17, 2001
Posts: 227
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

Joined: Nov 22, 2008
Posts: 18944
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.
 
jQuery in Action, 2nd edition
 
subject: Making a servlet wait for a response?
 
Similar Threads
How to display an Intermediate Page during a form Submission ?
Thread question
encryption/decryption in servlets
How can I serialize thread handling with Java 5's java.util.concurrent package?
Q on threads (2): synchronized and wait