0

I am displaying 100 list of records along with images and image coming form servlet.

Now thing is that i am loading image for later use like for poup thing.

so Is there any way that i can load this images as background process which is not interrupt page loading.(Currently it is taking 20 mins to load whole page just due to image servlet)

Any way like using ajax call as background process like or some other way using java.

Any suggestions would be appreciate.

Thanks.

Ruchi
  • 5,032
  • 13
  • 59
  • 84

3 Answers3

0

If it takes 20 minutes I would personally create a servlet that creates an html page ex. myresult.html If it's not done or a request is already in process I would return "in process, please wait" or something similar, When it's finished I would redirect/load to the newly created html.

If you want to make it with javascript following the same idea instead of returning a message you could return a JSON message, Javascript variable what have you... and check this message with some periodicity ex. setTimeout(checkMessage, 60000);

UPDATE

If you just need to load some images after the main page has been loaded you could use some javascript functions to load the images when the page has been loaded event on load, or if you are using jquery when the page is ready and then load the images asynchronously with jquery here or just with plain javascript here

I hope this helps.

Community
  • 1
  • 1
PbxMan
  • 7,525
  • 1
  • 36
  • 40
  • I have already put "please wait" kind of message when page is loading but still this page sometimes take more time to load and i think it is just due to if i remove this then page load within 2 mins.I just need to load div which contain image using background process because this image is not directly shown on page but i have put this on Hover popup. – Ruchi May 28 '13 at 08:32
0

I think you can learn asynchronous coding with javascript. For example,

f1(); // We assume f1() will take a long time and it will block page loading.  
f2(); // And f2() must be execute after f1()
// Other code here will be blocked by f1()

We can simply use setTimeout() to execute f1() asynchronously like this.

function f1(callback){
setTimeout(function () {
    // Here is the work will do in f1()
    // You can move upper f1() code to here
    callback();
}, 20 * 60 * 1000);
}

f1(f2); 
// Other code here without being blocked by f1()

More asynchronous coding tips can be found here : http://sporto.github.io/blog/2012/12/09/callbacks-listeners-promises/

Le Wang
  • 76
  • 2
  • From your comment, i think you can remove or replace it with . And in $(document).ready(function(){ /*replace you img tag or update the src attribute of you img tag */ }); @Sweety – Le Wang May 28 '13 at 09:00
0

Your Servlet should just create the list of records. Later you should load images using ajax calls.

Rajender Saini
  • 594
  • 2
  • 9
  • 24