问题
I stored huge(above 20000) records in StringBuffer for displaying in a jsp. I used StringBuffer to store in servlet and pass this as request attribute to jsp. The problem is that it takes too mush time to load all the records. After loaded, the browser is getting slow. Is there any best way to load huge records in a single jsp page ? or otherwise how to read data from StringBuffer fastly?
回答1:
I'm pretty sure the problem doesn't come from the StringBuffer or from the HTML code generation by the JSP. The problem probably comes from:
- the time it takes to load all this information from your database
- the time it takes to transfer a huge HTML page from the server to the client. Bandwidth is not unlimited
- the time it takes for the browser to parse and render a huge HTML page
Anyway, I very much doubt a user will be able to find what he's interested about in a page containing 20000 records. Provide a search interface rather than showing everything, and only display pages of 20, 50 or 100 records at once, like nerly every web site does (think Google: all the results are not displayed in the result page, but only the few first ones).
来源:https://stackoverflow.com/questions/10734751/performance-issue-to-load-huge-records-in-a-single-jsp-page