Problem processing large data using Applet-Servlet communication
I have an Applet that makes a request to a Servlet. On the servlet it's using the PrintWriter to write the response back to Applet:
out.println("Field1|Field2|Field3|Field4|Field5......|Field10");
There are about 15000 records, so the out.println() gets executed about 15000 times.
Problem is that when the Applet gets the response from Servlet it takes about 15 minutes to process the records. I placed System.out.println's and processing is paused at around 5000, then after 15 minutes it continues processing and then its done.
Has anyone fac开发者_如何学Ced a similar problem? The servlet takes about 2 seconds to execute. So seems that the browser/Applet is too slow to process the records.
This is the Applet code. Sometimes it just stops on the first System.out and sometimes stops on the second System.out.
while ((line = in.readLine()) != null) {
System.out.println("Reading from stream....");
datavector.add(line);
System.out.println("Vector size="+datavector.size()+" Line added="+line);
}
Any ideas appreciated.
Thanks.
Is you question related to "processing being paused around 5000 records and then starts on its own after 15" ? OR it is processing being slow on your applet
It will be helpful if you code post some code snippet?
Remove the System.out.println()
lines from the while
loop. You're per saldo calling System.out.println()
30,000 times. That would add much overhead. Just place one before and one after the while
loop if you want.
精彩评论