This discussion is archived
6 Replies Latest reply: Nov 16, 2012 3:37 AM by 967350 RSS

Display image problem in firefox code in jsp and servlet

967350 Newbie
Currently Being Moderated
Hi sir,

I am developing an web application with servlets and jsp. I have an issue to store images. I am storing images in folder and their relative path's in mysql database.


when I retrieve path from database then using <IMG> tag i have displayed image like:

     out.println("<td><img src="+user.getPlaceImage()+" width='70' height='50' /></td>");

It is working fine with internet explorer but not working (that is Not displaying image) in chrome/mozilla.

How to display that image in all browsers....

please reply me as soon as possible.


Thanks in advance..
  • 1. Re: Display image problem in firefox code in jsp and servlet
    967350 Newbie
    Currently Being Moderated
    need help to create code with browser compatiblity
  • 2. Re: Display image problem in firefox code in jsp and servlet
    gimbal2 Guru
    Currently Being Moderated
    Why are you doing out.println's when you are using JSPs ?

    You need to have a look at the HTML source in the browser and see what URL actually ends up in the image tag. Something is wrong with it.

    PS: when you post code, please use \
     tags to make it readable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
  • 3. Re: Display image problem in firefox code in jsp and servlet
    967350 Newbie
    Currently Being Moderated
    Thanks for reply,

    now i am trying to use JSTL tag to retrive the images. can u tell me these would compitible with any browser or i need to use Ajax to calling jsp page.

    Thanks
  • 4. Re: Display image problem in firefox code in jsp and servlet
    gimbal2 Guru
    Currently Being Moderated
    JSTL or Ajax has absolutely nothing to do with any of it. You seem to lack fundamental understanding of how server side technology (java,jsp) and client side technology (html, javascript) fit into the larger picture. Its not JSTL or Java displaying the image, its the browser on the client that does it. The browser needs to be able to fetch this image from somewhere; that 'somewhere' is what you stick in the HTML image tag.

    Forget about the Java and JSTL stuff for now; try to create a simple webpage that just displays an image. When you get that to work, try to change it by making Java put in a specific image URL.
  • 5. Re: Display image problem in firefox code in jsp and servlet
    967350 Newbie
    Currently Being Moderated
    hi,

    we are trying to retrive the images by using jstl tag. actually i am storing my images in my local drive path (D:\\img\\image1.jpg) and trying to retrive those images with imageId. line no 1,2 and 4 for imageid , placeid and imagepath is showing in the output. but line no 3 return its alt property. this only happening with mozila firefox but internet explorer showing all the output properly.

    {

    1)<td>${heritage.imageId}</td>
    2)<td>${heritage.placeId}</td>
    3)<td><img src="<c:url value="${heritage.placeImage}"/>" alt="Test Image 1" width="70" height="50"/></td>
    4)<td>${heritage.placeImage}</td>

    }

    Actually I have to upload 20000 images into my sql database if I store all images to Mysql database as Blob type the performance is reduced and It will slow down if we upload other images if required.To avoid this problem I am storing all images into folder and their path's into mysql database table.and retriving these images with pagination If there is any alternative way to deal with this problem please reply me as soon as possible...

    thanks in advance
  • 6. Re: Display image problem in firefox code in jsp and servlet
    967350 Newbie
    Currently Being Moderated
    Here is my controller to call DisplayImage1.jsp. and i have also set attribute to session object variable. these variable accessing all the list value in DisplayImage1.jsp.
    thats why i am using jstl tag to retrive those setter & getter variable value.

    {

    session.setAttribute("heritageSearchInfo",list);

    RequestDispatcher dispatcher = req.getRequestDispatcher("/DisplayImage1.jsp");
                             dispatcher.forward( req, resp);          

    }


    plz reply
    thanks

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points