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.

You should not crosspost questions. It is rude and a waste of our time.
Please stick to one topic: [http://forums.sun.com/thread.jspa?threadID=5372144].

Similar Messages

  • How to change images dynamically in jsp?

    Hi All,
    i Want to know how to change images dynamically in jsp, for example in any site if u look at advertise or any images, it will be changed after every few seconds.
    Please guide me
    Thanks
    Sandesh S

    sandeshas wrote:
    Hi BlusC,
    i was searching your mail Id to ask the question directly to u,i checked in your blog also, but i didnt get,I want to keep my email spam safe. Only trusted people and direct friends have it. Just use the forums for discussion.
    my question is suppose if i want to display and change the advertise(adds from different company ) in my web site,how can i do it by using jsp?
    Do i need to create animated gifs which contains all company adds??one might be from movie add,after few seconds next one migth be some other web site add like that, how can i achieve this in my servet,jsp or using struts.You create animated gifs with an [animated gif editor|http://google.com/search?q=animated+gif+editor]. There is nothing what JSP can do for you here.

  • Display Images Dynamically

    Hai
    I am new to Jdeveloper. I have a task to display images dynamically.
    <img src="file:///Z:/Image/sample.bmp "
    alt="images" />
    i am using mysql database.i am getting the path from database.
    Now i want to pass the path of the image file.how can i do it
    If anybody knows please tell me
    thanks
    raju

    Hi,
    Assuming that your technology is ADF/JSF .... you only need to create a binding for the image source attribute and then use an af:objectImage tag to display the image. You could use for example something like this :
    <af:objectImage source="#{bindings.ImageSource.inputValue}"/>Just remember that in order for the image to display correctly, the path from the database has to be relative to your web root.
    Thanassis

  • Display Image in another jsp

    hello,
    I am facing a design issue of so as to how to go about displaying an image which i am retrieving from database.
    I have a SubmitDoc.jsp which takes as input the doc id which i need to display looks like :
    *SubmitDoc.jsp*
    <FORM METHOD=POST ACTION="Retrieval">
    Enter Document ID to Retrieve: <INPUT TYPE=TEXT NAME=DOCID SIZE=20/><BR>
    <P><INPUT TYPE=SUBMIT></P>
    </FORM>I have my Retrieval servlet which access the DB and gets the binary stream for the image data based on DOCID.
    Now i try to forward result to a different jsp in order to display the binary data from the servlet.
    something like this :
    InputStream readImg = rs.getBinaryStream("DOCUMENT");
    response.setContentType("image/jpg");
    request.setAttribute("ImageData", readImg);
    // response.getOutputStream().write(rb,0,len);
    RequestDispatcher rd = request.getRequestDispatcher("DisplayDoc.jsp");
    rd.forward( request, response );What code should i put in DisplayDoc.jsp to show the image there.
    Any ideas how do i go about ?
    Thanks,

    What code should i put in DisplayDoc.jsp to show the image there.The same code you put in any html page to show an image:
    <img src="urlToDownloadImageFrom"/>In effect you have two requests.
    One for the JSP page, and then another for the image.
    So often what you find is the tag on your page needs to pass the id as well
    <img src="/ImageServlet?docId=abc123"/>

  • Displaying Image on th JSP page

    Hello All,
    I am using following code to display the image on the JSP page in my iView
    <% String PublicURL = componentRequest.getPublicResourcePath()+ "/images/Image1.gif"  ; %>
    <hbj:image id="Logo" width="70" height="35" 
                               src="<%= PublicURL %>"
                               alt= "picture Ericsson.gif" />
    Am I missing anything. I am still not able to display the image.
    Regards,
    Sanjeev

    change
    componentRequest.getPublicResourcePath()
    to
    componentRequest.getWebResourcePath()

  • Displaying image dynamically

    Hi,
    i am getting data from backend sys its working fine.
    when eve we r give input like material number like 1, 2, ....... then then press button it shows data and IMAGE also
    here i have taken images 1.jpg, 2.jpg, .......... workspace -
    > mimes-----> comp.............
    i am setting source of that image prop like 1.jpg here
    when i give input   1   and click button it display r/3data and image but it is used for that only. if i want to display 2  then i change image prop source (here material number is 1 and image is 1.jpg.........depends up on material num can we write code here)
    i want to display it dynamically (depends upon material num it can show the data and image)
    can any one help
    Regards
    bhanu

    Hi Nikhil,
    i am explaining about my thread clearly
    i have taken 1.jpg, 2.jpg, 3.jpg....... images in workspace ..mimes ... components ... packageee
    now take button and image with  visible prop
    In  init() method i have take instance,bind for backend data
    setting visible prop none(image)
    In onaction()
    have taken execute,invalidate in try catch
    setting visible prop is visible(image)
    when i give material no  1  then it can display output  data and image
    if i want to display material no 2 data
    when i give  material no 2 then it can display output data  but image is 1.jpg  b'coz  i set source of image porp as 1.jpg
    the above posted code i have taken in onaction button().
    through hard coding i can display it individually but i want to display it dynamically  likee
    when we give material no 1 it can display 1's data and image 
    when we give material no 2 it must  display 2's data and image
    can u explain me clearly if possible with step by step.
    sorry for the late reply
    Regards,
    bhanu.

  • How to display graphics dynamically in JSP

    I use JSP to call a servlet to get the output . The output is in svg format. I do not hope to create a svg file to store the output from servlet. I wope to embed the svg dynamically in the jsp page
    Anybody knows the solution. Many thanks in advance
    Cheers,
    .

    Because the output from Servlet is in text format not binary.
    So the tag <IMAG></IMAG> does not work .
    the output is similar as
    <svg viewBox="0 0 360 270">
    <style type="text/css"><![CDATA[
    .aS{ font-family: monospace; text-anchor: middle;
    font-size: 35px; stroke: Blue; fill: Red; }
    ]]></style>
         <g>
    <text x="60" y="90">+2%</text>
    <polyline points=" 110,80 110,80 210,80 210,80" />
    <text x="60" y="180">-2%</text>
    <line x1="110" y1="170" x2="210" y2="170" />
    <line x1="110" y1="120" x2="210" y2="120" />
    <text x="280" y="130">4:0</text>
    <text x="160" y="200">1</text>
    <text x="110" y="150">-</text>
    <text x="185" y="50">Sample - Name</text>
    <text x="185" y="240">Minutes/km (2003/1/7)</text>
         </g>
    </svg>
    If I keep the output as a **.svg file. then embed it in jsp. it is OK.

  • Display Images dynamically on a servlet

    I saw postings earlier on this topic and adopted the suggestions given , but I can display only a single image.This works for a single image jpg .All the files uploaded are
    into c:\temp. The Servlet program parses through the dir and picks up
    only jpg's (since I want to display all jpg's first and then expand to
    gif's).The servlet now displays only an icon but no images .
    I initially brought all the images in to a ArrayList but I thought its
    better to display directly from the filesystem.
    Please let me know what is the problem
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import javax.swing.*;
    import com.sun.image.codec.jpeg.JPEGCodec;
    import com.sun.image.codec.jpeg.JPEGImageEncoder;
    import com.sun.image.codec.jpeg.* ;
    * @author
    public class DisplayImage extends HttpServlet
    java.util.List aList = new ArrayList();
    public void service(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException
    String path= "c:\\temp\\";
    File f = new File(path);
    String[] dirList = f.list();
    int l=100;
    int k=100;
    response.setContentType("image/jpeg");
    OutputStream out = response.getOutputStream();
    PrintWriter out = response.getWriter();
    for( int i = 0; i < dirList.length; ++i )
    String fExt= "jpg";
    // System.out.println(">>The files in the dir are>>:"+dirList[i] );
    String filename = dirList.toString();
    // System.out.println("FileName is"+filename);
    int sLength = filename.length();
    int sLastIndex = filename.lastIndexOf(".",sLength);
    //System.out.println(">>Last Index Value>>"+sLastIndex);
    String imageExt = filename.substring(sLastIndex+1,sLength);
    //System.out.println(">>ImageExtensionis>>"+imageExt);
    if(imageExt.equalsIgnoreCase(fExt))
    String imagefilename = path+filename;
    //System.out.println(">>Final filename is>> "+imagefilename);
    Image myImage = new ImageIcon(imagefilename).getImage();
    BufferedImage outImage = new BufferedImage(10,10 ,BufferedImage.TYPE_INT_RGB);
    Graphics2D d2g = outImage.createGraphics();
    d2g.drawImage(myImage, l, k, null);
    //AffineTransformOp afo = new AffineTransformOp(af,1);
    //BufferedImageFilter bf = new BufferedImageFilter(afo);
    //d2g.drawImage(myImage, null, l,k);
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    encoder.encode(outImage);
    k+=100;
    else
    System.out.println(">>Not a jpeg file>>");
    out.close();

    Thanks for the reply.
    What I intend to do is :
    1.Displa.jsp calls a servlet DisplayImage
    2.DisplayImage goes to a known directory in the filesystem and picks up all images.
    3.Display all the images on the servlet at once in thumbnail fashion.
    4.Click on each image to enlarge it.
    So far I am stuck at step 3.
    So how do I proceed about on this problem , do I need to open and close the request in the for loop each time?

  • Problème images dynamiques via xml

    Bonjour aux Dieux de l'actionScript
    Que vous etes grands, que vous etes beaux, et que vous etes forts !!!!!
    J'ai besoin de votre aide car je suis en train de m'arracher tous les cheveux et après mon mari va pas être content (faut dire une fille sans cheveux !)
    J'essaye de construire une bibliothèque virtuelle pour l'école de mes enfants.
    La présentation se fait par un coverflow (protoflox en l'occurence auquel j'ai intégré shadowbox). Il y a donc des images de livre, quand on clique dessus cela ouvre la shadowbox qui affiche un swf (avec la même couverture de livre) sauf que là la partie de gauche est un bouton qui ouvre le livre et la partie de droite est également un bouton qui ouvre un résumé du livre. Le premier swf, je l'ai fait manuellement (pas de problème), mais comme j'ai toujours plein de bonnes idées, je voulais que cela ce fasse dynamiquement via un fichier xml (cela permettait aux profs de pouvoir le modifier sans réellement toucher au swf).
    J'ai donc fait mon xml:
    <?xml version='1.0' encoding="UTF-8"?>
    <main>
    <image
    src="sophie-livre.jpg"
    width="351"
    height="405"
    getURL="./Livres/segur/paul/index.html"
    info="_blank"
    texte="Voir le livre"/>
    <image
    src="sophie-resume.jpg"
    width="351"
    height="405"
    getURL="./Resume/segur/paul/index.html"
    info="_blank"
    texte="Lire le résumé"/>
    </main>
    Ensuite j'ai mon fichier fla; dans action, j'ai misle code suivant:
    Mon xml est bien chargé, il m'affiche les 2 images sur ma scène.
    Les soucis:
    1) Lorsque je teste l'anim ou que je l'affiche dans IE, j'ai les images. Mais dès que je teste dans EasyPhp, la shadowbox est vide.
    2) Je n'arrive pas à faire de ces 2 images des images cliquables ( soit avec le petit curseur main)
    Faut avouer je suis meilleure en patisserie !
    J'essaye de vous mettre le swf que je voudrais reproduire.
    http://www.files-save.com/fr/download-f7502bc012152ca77e44d67824ab0759.html
    Merci de votre aide

    Hi sarahbmc,
         Please tell your problem in english.

  • Dynamic Image rendering on JSP page

    Hi All!
    I want to display images on my JSP page. However, the images should be generated dynamically (As are used by many sites during the registration process e.g., yahoo, etc..) How can i achieve this?
    plz help! Its urgent!

    Yes, but your in the wrong forum for this.
    Use the search bar to look for posts and have a look in
    http://forum.java.sun.com/forum.jspa?forumID=5
    There are forums on Multimedia which may also have some information.

  • Problem in displaying images

    Dear JSP/Servlet experts,
    I have problem in displaying images on a JSP page. I stored all the images names in a database and
    try to retrieve them based on the user selection. When the JSP page is load for the first time the
    following error occur but the images are displayed correctly:
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover150.jpg + null) Connection aborted by peer: socket write error
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover154.jpg + null) Connection aborted by peer: socket write error
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover152.jpg + null) Connection aborted by peer: socket write error
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover151.jpg + null) Connection aborted by peer: socket write error
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover156.jpg + null) Connection aborted by peer: socket write error
    Here is the code to display the images(the getCover() method will return cover150.jpg, cover151.jpg.... )
    and the images are stored in /simple/images folder
    <td><a href="<img src="/simple/images/<%= b.getCover() %>" alt="details"></td>

    try this
    <img src=/simple/images/<%=b.getCover() %>
    vasanth

  • Display images like in images search engines

    I have a list of images that I want to display like the results in yahoo image and google image search engines.But when i use tha datatable component I can just display one column.And after I want to do something after that the user clicks on an image for example displaying it with real size not in thumbnail mode.
    I also tryed using the image browse widget and the yahoo carousel but I dont know how to hand events and how to know which picture is selected.
    Can you please help me.
    Thanks in advance

    fiedlerm wrote:
    I try to display workspace Image in a HTML Region dynamically.
    The Image Source is stored in a hidden Item filled by an application process.
    Region - Source:Always post code using <tt>\...\</tt> tags.
    <img src="#WORKSPACE_IMAGES#Sunny.gif">
    <br></br>
    &P1_ICON_SRC.
    <br></br>The first "hardcoded" Image was displayed.
    The second "dynamic" Image shows the following Text in the HTML - Region:
    <img src="wwv_flow_file_mgr.get_file?p_security_group_id=7856557026011968186&p_fname=Blizzard.gif"> Hidden page items cannot contain HTML mark-up. Look at the page source. When the item is rendered its value is contained in the hidden <tt>input</tt> element's <tt>value</tt> attribute:
    <input type="hidden" name="p_t01" id="P1_ICON_SRC" value="&lt;img src=&quot;wwv_flow_file_mgr.get_file?p_security_group_id=7856557026011968186&amp;p_fname=Blizzard.gif&quot;&gt;">The value must be properly HTML-escaped like this otherwise the browser would see it as tag soup:
    <input type="hidden" name="p_t01" id="P1_ICON_SRC" value="<img src="wwv_flow_file_mgr.get_file?p_security_group_id=7856557026011968186&p_fname=Blizzard.gif">">What exactly are you trying to achieve?
    Options for displaying images dynamically would include putting the required mark-up in an HTML region, only storing the image URI (or parts of it) in the page item, and referencing this using static text substitution. Others would be custom report templates or Dynamic PL/SQL regions.
    If you must store HTML code in session state and access it using static text substitution (not recommended) then use an application item.
    h4. Page Process
    begin
      :P1_ICON_SRC := 'Blizzard.gif'; -- Hidden page item
      :F41327_ICON_SRC2 := '<img src="#WORKSPACE_IMAGES#Blizzard.gif">'; -- Application item;
    end;h4. HTML region source
    <img src="#WORKSPACE_IMAGES#Sunny.gif">
    <br></br>
    <img src="&WORKSPACE_IMAGES.&P1_ICON_SRC.">
    <br></br>
    &F41327_ICON_SRC2.

  • How to display images and information

    how to display images and information(e.g. like questions) on a jsp page that stored in a database

    Look As far as i can see....
    Utlimately every file could be expressed as a bytes buffer.
    so say if you have a bean called Choice Bean which is expressed as
    public class ChoiceBean{
       private String choiceid;
       private String choicedesc;
       private byte image[];
       public void setChoiceId(String choiceid){
              this.choiceid = choiceid;
        public String getChoiceId(){
               return this.choiceid;
          public void setChoiceDesc(String choicedesc){
               this.choicedesc = choicedesc;
           public String getChoiceDesc(){
               return this.choicedesc;
           public void setImage(byte image[]){
                  this.image = image;
             public byte[] getImage(){
                  return this.image;
    }QuestionList.java:
    ===============
    public class QuestionList{
         private List<ChoiceBean> choicelist;
          /*Other member variable declarations*/
           public  List<ChoiceBean> getChoiceList(){
                    /*Custom code where you may build the list by querying the DA layer*/
                     return this.choicelist;
         public int search(String choiceid){
                 int index = -1;
                 for(int i =0 ; i < this.choicelist.size() ; i++){
                        ChoiceBean cb = this.choicelist.get(i);
                         if(cb.getChoiceId().equals(choiceid)){
                                index = i;
                                break;
                 return index;
        /* Other member method declarations */
    }and you are retreving List<ChoiceBean> from DB using your query & have created a session attribute / <jsp:useBean> named ChoiceList
    NOTE: sometimes your application server can go out of bounds as you are consuming a lot of memory by creating an arraylist object.
    use the following methodology to display images & choices
    sample.jsp:
    =========
    <jsp:useBean id="QuestionList"  class="com.qpa.dao.QuestionList" scope="session"/>
    <TABLE>
    <%
    /* QuestionList.getChoiceList() is a method which fetches data from the DB & returns it in form of  List<ChoiceBean> */
    List<ChoiceBean> choicelist = QuestionList.getChoiceList();
    for(int i =0 ; i < choicelist.size() ; i++){
    %>
    <TR>
    <TD><%!=choicelist.get(i).getChoiceId()%></TD>
    <!-- calling servlet which renders an images in JPG format based upon given choiceid(unique field) -->
    <TD><IMAGE src="ImageServlet?choiceid=<%!=choicelist.get(i).getChoiceId()%>"/> </TD>
    <TD><%!=choicelist.get(i).getChoiceDesc()%></TD>
    </TR>
    <%
    %>
    </TABLE>
    <%
        session.remove("QuestionList");
    %>
    NOTE: usage of JSTL or any other custom built tag-libraries makes life more simpler in the following case
    ImageServlet.java:
    ===============
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            byte buffer[] = null;
            HttpSession session = request.getSession(false);
            /*getting the QuestionList from the session*/
            QuestionList ql = null;
            String choiceid = new String("");
            try{
                 choiceid = request.getParameter("choiceid");
                 /*getting the QuestionList from the session*/
                ql = (QuestionList)  session.getAttribute("QuestionList");
            } catch(Exception exp){
            if(choiceid.equals("") == false &&  ql != null ){
                List<ChoiceBean> clist = QuestionList.getChoiceList();           
                   assuming that you have created a serach method which searches the entire choice list and would give you
                   the index of that object which is being refered by unique choiceid and returns -1 if not found
                int index =  QuestionList.search(choiceid);
                if(index != -1){
                   ChoiceBean cb = clist.get(index);
                   buffer = cb.getImage();
            if(buffer != null){
                 // assuming that we have stored images in JPEG format only
                 JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(new ByteArrayInputStream(buffer));
                 BufferedImage image =decoder.decodeAsBufferedImage();
                 response.setContentType("image/jpeg");
                 // Send back image
                 ServletOutputStream sos = response.getOutputStream();
                 JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(sos);
                 encoder.encode(image);
            } else {
               response.setContentType("text/html");
               response.getWriter().println("<b>Image data not found</b>");              
    }However,i still feel there are few loopholes with this approach where Application Server can eat up a lot of heap space which may result in outofmemorybound exception.
    Hope this might help :)
    REGARDS,
    RaHuL

  • Displaying a dynamic image in a jsp

    I am interested in the way of dynamically generating an image in a web browser. The image should be formed on the servlet, more precisely with the aid of a servlet, and reloaded in the web browser every time it suffers modifications (for example, elements are drawn). The drawing and displaying part is already functioning not as a server application, but as a desktop one. The result of the drawing actions are displayed in a Bufferd Image view. What I have to do is to display this image in the browser, encoded as a gif (I already know how to do the encoding part).
    //code from TheServlet.java
    ImageViewPort view = new ImageViewPort(600, 600); // BufferedImage type
    Image image = view;
    g = image.getGraphics();
    response.setContentType("image/gif");
    GifEncoder encoder = new GifEncoder(image, out);
    encoder.encode();
    How would I correctly reference in the HTML form this servlet? In the HTML form I have to display the dynamically created GIF image as a server side image map?
    // code from the HTML form
    <img WIDTH=600 HEIGHT=600 BORDER="2" src="http://localhost:8080/servlet/TheServlet");
    ISMAP/>
    How should be written the source of these image map?

    you can use AJAX for this.. google maps is using ajax for rendering their maps..

  • How to display images on local disk(outside of WebContent of WAR) in jsp?

    In a web application, I want to display images on local disk(outside of WebContent of WAR) in jsp. I couldn't put it in "WebContent/images/" because the images are portraits of users and they could be changed dynamically. If I put images in "WebContent/images/", I have to transfer the images back and forth every time when I update my WAR file.
    Obviously, in jsp, something like
    "<img src="/home/username/images/local/PRTR.jpg" />"
    doesn't work.
    Is it durable to store the images at somewhere else like "/home/username/images/local/" in the server's local disk?

    Hi aiGrace,
    You have to transform your file path into the appropriate URL, this way :
    try {
        File file = new File("D:/Test/MyPic.jpg");
        System.out.println(file.toURI().toURL());
    } catch (MalformedURLException ex) {
        ex.printStackTrace();
    }Then, you insert the URL in your img tag.

Maybe you are looking for