I came across my posts which answer this question.But i am not able get an idea of how i can implement in my program.My requirement is as follows.
from a jsp page i call a servlet using ajax call:
$(document).on('click' , '#gettopevents' , function(event) {
var field = $("input[name = 'field']").val();
if(field === "")
{
$('#responsemsg').html("enter a field");
}
else
{
var dataform = { 'field' : field };
$.ajax({
url : 'GetAllLogs',
type : 'POST' ,
data : dataform ,
success : function(response) {
$('#displaylist').load('listgeneration.jsp');
},
error : function(){
alert("error");
}
});
}
event.preventDefault();
});
The servlet execution is an intence process and it takes some time.So i need to show a progress bar to the user regarding the execution status of servlet. More specifically i need it to be as.
@WebServlet("/GetAllLogs")
public class GetAllLogs extends HttpServlet
{
public void doGet(HttpServletRequest request , HttpServletResponse response) throws ServletException , IOException
{
PrintWriter obj = response.getWriter();
obj.print(10);
// at this point i need to set the progress bar value to 10%
....
....
obj.print(40);
// at this point i need to change the progress bar value to 40%
.....
.....
obj.print(100);
//at this point i neet to change the progress bar value to 100%
}
}
basically i need to update the status bar for ever print value in the servlet.Is this approach possible and how can i do it. Thanks in advance