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

Asynchronous response handling.

Nitish Kumar Singh

Joined: Aug 16, 2013
Posts: 5
Can anyone help me, with this scenario...

There are three submit buttons: button1, button2, button3 in a home.jsp page. When user clicks on button1 , request is send to servlet1 which calls a java code to copy a file (30 mb) from one location to another. Similarly, button2 calls servlet2 which does same thing and button3 calls servlet 3 which does same thing. So there are three different file which are being copied simultaneoulsy. Now as they are being copied in background, user moves to home.jsp page. This home.jsp page has two parts, one contains button1, button2 and button3 and second part is blank. When servlet1 starts the first copying process, text should be displayed in home.jsp that file is getting copied, similarly for servlet2 and servlet3. Once file is being copied, info should change to, "File has been copied successfully". If any error occurs, that should be displayed too.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

Welcome to CodeRanch!

It sounds like you want to use AJAX. Each process would put an attribute in the session with the status ("copying file 1", "finishing copying file 1", etc). Then the JSP/HTML page could poll the server for that status and display it to the user.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Nitish Kumar Singh

Joined: Aug 16, 2013
Posts: 5
Thanks, but this is not what I meant.
Suppose there is another jsp page , say info.jsp. This jsp page records the info for all the process going at back end. At any time of day if I click and open this page, then i should get the info of process which failed which succeeded.


Process 1 - successfully deployed
process 2 - error occured
process 3 - Deploying.
Process 4 - Deploying.
Process 5 - successfully deployed

I will open this page after long time, till then all info should be recorded. Sessions i cant use because there are 1000 such processes.
Sourabh Bawage
Ranch Hand

Joined: Sep 03, 2013
Posts: 33

you will definitely need to store the information about the processes in the Database.....

I agree. Here's the link:
subject: Asynchronous response handling.
It's not a secret anymore!