I have an requirement is like this, Servlet is processing some data for this it will take some time. For every second or minute i need display servlet process statements in jsp. Using AJAX it will appends total response at a time but i need append line by line message.
1) the server sends the full list every time and the client replaces the local display with the data from the server (easier but problems if the data becomes large)
2) the client sends the timestamp (as determined by the server) of the last message update, the server responds with an updated timestamp and any new messages since the last update. The client appends the updated info to the page.
Joined: Mar 28, 2011
Example message in jsp:
File1 is processed successfully..........
File2 is processed successfully..........
File3 is processed successfully..........
That's not going to happen easily. A single servlet invocation is not going to be able to have that sort of back-and-foth interaction.
What you can do is to have the first servlet kick off a back-ground thread to perform the lengthy operation, and then have Ajax kick off "progress check" requests that can synchronize with the working thread to determine what to report as done.
Otherwise, you'll have to make each "line" a separate serial request.
Can you write a sample code for your explanation. In my program am calling Servlet once Servlet is internally calling Thread class many times based on the files we are passed. Again this Thread class is calling another Thread class for dividing the records in the file.