This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
JSP response time on ajax data...my JSP hangs when data is very large!!!!
ishan grover
Greenhorn
Joined: Feb 29, 2012
Posts: 6
posted
0
Hello to all the java ranchers... i have made a auto suggest in struts 1.3 using Jquery.js, JSON.js, and ajax...
Following is the scenario : User enters anything on the textbox..on its "Onkeyup" event the data is passed to ajax function of Jquery...n then to the action..now it executes the query like :select * from candetails where fname ilike 'data passed %'
now the result of the query comes to ajax function and it displays it on the table in my JSP page..
but the problem here is when the data is large then the page hangs up and when i kill the javaw.exe process then the results comes in or i have to wait for a long time to get the values in the table...in case of normal data it is working fine...
can anyone tell me how to decrease the response time in such a scenario or how to deal with this problem ???
any help would be appriciated...thanking you all!!!
If anyone needs the code for this i will post it...
Regards
Ishan
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2407
posted
0
You may want to limit the data being selected to a reasonable amount, maybe the top 100 results ("... LIMIT 100" in the SQL). That should be easily manageable.
Or simply don't return anything if there are too many results, and wait for the user to enter more characters.
ishan grover
Greenhorn
Joined: Feb 29, 2012
Posts: 6
posted
0
Tim Moores wrote:You may want to limit the data being selected to a reasonable amount, maybe the top 100 results ("... LIMIT 100" in the SQL). That should be easily manageable.
Or simply don't return anything if there are too many results, and wait for the user to enter more characters.
thanks for your reply Tim.. i know about limit thing but i am looking for a way if there is : to reduce the page load..is there any way for that..cache control etc anything like that...that would be really helpful!!
otherwisewe'll allow user to enter more characters...thats not an issue..
thanks for the reply!!!
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2407
posted
0
There are many ways to tackle this, but the best is to limit the amount of data from the start. Realistically, a user is not going to look at even 50 results being displayed, so there's no point in retrieving more from the DB to begin with.
I agree with Tim that in most of the cases it is completely pointless to show a user a tremendous amount of options so your best bet would indeed be to start of by limiting the number of rows returned. Another option would be to use a cache (if you are not already doing to implicitly). The cache could store the result of your query in memory thus preventing further requests from accessing the database again and again for the same data. Ofcourse, you would have to allow the application to run the query once entirely for the cache to be correctly populated.
SCJP 6, OCWCD 5, SpringSource Spring 3 Certified Professional (92%)
ishan grover
Greenhorn
Joined: Feb 29, 2012
Posts: 6
posted
0
Marc Rooding wrote:I agree with Tim that in most of the cases it is completely pointless to show a user a tremendous amount of options so your best bet would indeed be to start of by limiting the number of rows returned. Another option would be to use a cache (if you are not already doing to implicitly). The cache could store the result of your query in memory thus preventing further requests from accessing the database again and again for the same data. Ofcourse, you would have to allow the application to run the query once entirely for the cache to be correctly populated.
Thanks for your suggestion. i made this program to understand the flow of things.
now i'll do R&D on what you have suggested about the cache thing..
Thanks for your post again...cheerzz !!! javascript:emoticon('');
Marc Rooding wrote:I agree with Tim that in most of the cases it is completely pointless to show a user a tremendous amount of options so your best bet would indeed be to start of by limiting the number of rows returned. Another option would be to use a cache (if you are not already doing to implicitly). The cache could store the result of your query in memory thus preventing further requests from accessing the database again and again for the same data. Ofcourse, you would have to allow the application to run the query once entirely for the cache to be correctly populated.
Thanks for your suggestion. i made this program to understand the flow of things.
now i'll do R&D on what you have suggested about the cache thing..
Thanks for your post again...cheerzz !!! javascript:emoticon('');
No problem :-) I don't know how you are connecting to the database (JDBC, Hibernate, JPA, ...) but if you happen to use Hibernate there is already support for caches. The first result on google which might be of interest (I have not read it): http://www.javabeat.net/2007/10/introduction-to-hibernate-caching/.
Wether or not you are using Hibernate, a good library for caching is EHCache (http://ehcache.org/)