SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Proble displaying images dynamically in jsp

    Hi, I am new here. I have to display the images dynamically reading from a database. I have no problem displaying images. When i try to reduce the width in img tag then it is slowly rendering it. How to overcome this.

    <img src="image.jsp?imgID=112" width="150" heigth="130" border="0">

    I am also giving the sample jsp to display

    byte [] imgData = blob.getBytes(1,(int)blob.length());
    response.setContentType("image/jpeg");
    OutputStream o = response.getOutputStream();
    o.write(imgData);

    I want to display the image without any time taken. How could I solve this. Please Help me.

    Thanks.
    Phani.

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2007
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    did you manage to find the bottleneck?
    I mean did it take time to read from DB? or it takes times in transporting the data through network? or it is just the JSP which is taking time to display the image?

  3. #3
    SitePoint Wizard
    Join Date
    Apr 2007
    Posts
    1,397
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You should check the original image size first. It is your "browser" that does the resizing. The best thing to do is to NOT specified the width size through HTML. So, change the source of the image file to be specificied dimension. Another advanced way of doing it is, resizing the image before it goes to the browser. I think I've done this long time ago but I can't remember exactly but it did have setWidth and setHeight method. I'm sure google will help you in this.

  4. #4
    SitePoint Zealot
    Join Date
    Dec 2008
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The things i'd recommend to do:

    1. Find the bottleneck with that issue - place timestamps on different image display stages and compare timing.
    2. I would not use the sizes in the IMG tag. I would not even resize them on the server side. If possible, i would pre-compute all needed sizes for all images and then just take the needed size by the image ID from the database..
    A huge list of resources for designers and content producers
    to buy, sell or share stock photo images and other content.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •