I am currently in the process of designing an application where I am executing HTTP POST requests using Angular. These requests are then received by Java code, which processes them and generates logs consisting of approximately 50-60 lines at a rate of one line per second. Instead of waiting for the request to finish before displaying all the logs at once, I would like to showcase them on my HTML page as they are being generated. Is there a way to achieve this continuously?
JAVA CODE
The Java code creates an array of logs with a size of 50-60. It takes about 60-90 seconds to complete the operation, and after converting the logs to JSON format, the array is sent using the following code:
response.getWriter.write(applogs)
JAVASCRIPT CODE
var httpPostData = function (postparameters, postData){
return $http ({
method : 'POST',
url : URL,
params : postparameters,
headers: headers,
data : postData
}).success (function (responseData){
return responseData.data;
})
}
var addAppPromise = httpPostData(restartAppParams, app);
addAppPromise.then(function (logs){
$scope.logs = logs.data;
})
HTML Code
<span ng-repeat="log in logs">{{log}}<br></span>