suppose i have a client which sends the request to server to generate numbers from 1 to 100 and send the response back to client. Assume that generating numbers from 1 to 100 is very tedious job and it requires lot of resources so my server will start generating the numbers and sends the numbers to client as soon as the number is generated on server, instead of generating all number and sending the response at once to client.
It is something like flipkart page. if you open a page we can see that, the page is keep on updating with new products at the bottom, instead of listing all products once at one shot.
Can any one please suggest me some efficient technique in java for my simple use case ?
This sounds like a job for Java 7's Websocket API. Using traditional HTTP it would not be possible because interactions followed a request-response pattern (although patterns such as polling and long-polling can achieve the same effect). WebSockets allow genuine push notifications from the server, so the client can receive the data as soon as it becomes available.