File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Communication between Servlet and Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Communication between Servlet and Thread" Watch "Communication between Servlet and Thread" New topic

Communication between Servlet and Thread

Gareth Western
Ranch Hand

Joined: Apr 07, 2004
Posts: 45

I have a (Struts) servlet which launches a Thread to perform a lengthy process. I'd like the user to be able to make subsequent requests in order to get a progress update from the thread, so they have some idea of how long until the thread completes.

Can someone provide some information on how I could do this? Doesn't have to be a very long explanation, just pointers on where to start looking for more information.


Travis Hein
Ranch Hand

Joined: Jun 06, 2006
Posts: 161
When you create the thread, can you place the handle to the thread instance onto the user's session?
Then the same user could see the status, any other page could session.getAttribute() to get the thread and ask thread.isAlive()

Error: Keyboard not attached. Press F1 to continue.
I agree. Here's the link:
subject: Communication between Servlet and Thread
It's not a secret anymore!