I have a problem and I'm hoping you can help me. I have a jsp that's displaying data, which length depends on the user. It takes up to 10 minutes sometimes to display a page. I don't want to break my page into multiple pages, but what I want to do is to display line by line on the screen as the data is being read. What happens now, is the browser waits until all the data is processed and then displays a page. Any ideas how to do this?

Alessandro A. Garbagnati

What you need should just be adding a:
out.flush()
every time you want to send something to the client.
Please, try this simple example, and let me know if this is an output that is similar to the one you're looking for.

<html>
 <head>
  <title>Slow Page Test</title>
 </head>
 <body>
  <h1>Slow Page Test</h1>
  <hr>
  <%
  	for (int x=0; x<100; x++) {
  %>
  <b>X is now <%=Integer.toString(x)%></b><br>
  <%
  		out.flush();
  		try { Thread.sleep(1000); } catch (Throwable t) {}
  	}
  %>
 </body>
</html>
Be careful that there are some cases where the browser needs to wait before displaying something. For example, if you have a table it is possible that the browser requires the entire table before being able to display the data... This is, unfortunately, not controllable.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact