0

Suppose there is a 4.3 mb png file.I used Balus c Image servlet to show the image inline in my jsp page.But the file being 4.3mb in size takes time to download.I would like to show a loading gif in the meantime and keep the image hidden by setting its style as "display:none;".The question is how do i know that the image has been delivered completely by the servlet before rendering the image.

jmj
  • 237,923
  • 42
  • 401
  • 438
sambit
  • 3
  • 1
  • In the code have you used any Input or OutPutstream because with the help of the stream you can verify that the image is loaded or not. – Ankit May 24 '11 at 07:05
  • possible duplicate of [jQuery "Please Waiting, Loading..." animation?](http://stackoverflow.com/questions/1964839/jquery-please-waiting-loading-animation) – jmj May 24 '11 at 07:05
  • response.setContentType("image/jpeg"); OutputStream stream = response.getOutputStream(); stream.write(new ImageResizerUtil().resizeImageAsJPG(data,500)); stream.flush(); stream.close(); – sambit May 24 '11 at 07:14
  • @jigar yes somewhat like that – sambit May 24 '11 at 07:15

1 Answers1

0

You can put the url of your gif image in the html produced by the jsp, then fetch the image at load time:

$(function() {
    var loadr = new Image();
    $(loadr).load(function() {
        $("#myimg").attr("src", this.src);
    });
    loadr.src = "servletUrl";
});
Maurice Perry
  • 32,610
  • 9
  • 70
  • 97