Dynamic display image

hi, everyone. i have a question on displaying image. for displaying image from a folder, i use:
<IMG src="/image/me.jpeg" >
But i can only display one image at one times. Is there ways to display images from folder dynamically?? Thank in advance.

if u are new to java.. then u may have to go thru some tutorials on servlets to get ur required job done. here are a list of online tutorials
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html
http://www.novocode.com/doc/servlet-essentials/
http://www.acknowledge.co.uk/java/tutorial/servlet_tutorial/
hope these will be useful for u.. u may have to spend some time on these...

Similar Messages

  • How to dynamically display images in JSPs

    This took a little while to figure out so I thought I'd share. After
              doing some research I was led to the following approach on how to load
              images from an Oracle database into a JSP:
              The "main" JSP:
              <HTML>
              <head>
              <title>Image Test</title>
              </head>
              <body>
              <center>
              hello
              <P>
              <img border=0 src="getImage.jsp?filename=2cents.GIF">
              <P>
              <img border=0 src="getImage.jsp?filename=dollar.gif">
              <P>
              world
              </body>
              </HTML>
              And this is the image getter:
              <% try {
              response.setContentType("image/gif");
              String filename = (String) request.getParameter("filename");
              java.sql.Connection conn =
              java.sql.DriverManager.getConnection("jdbc:weblogic:pool:orapool"); //
              connect to db
              java.sql.Statement stmt = conn.createStatement();
              String sql = "select image from testimage where filename = '" +
              filename + "'";
              java.sql.ResultSet rs = stmt.executeQuery(sql);
              if (rs.next()) {
              byte [] image = rs.getBytes(1);
              java.io.OutputStream os = response.getOutputStream();
              os.write(image);
              os.flush();
              os.close();
              conn.close();
              catch (Exception x) { System.out.println(x); }
              %>
              The thing to note is that there are no <%@ page import="..." %> or <%@
              page contentType="..." %> tags - just the single scriptlet. It
              seems that for every "<%@" the weblogic compiler sees it puts
              out.print("\r\n"); statements in the generated java source.(???) I
              don't know much about how browsers work but I think that once it sees
              flat ascii come at it it treats everything that follows as text/plain
              which is incorrect for the binary stream that's being sent. Another
              work around was to set out = null; but that's kind of ugly and might
              produce server errors. The real fix is to write a bean to handle images
              which I'll work on next (does anybody have any hints on how to do
              that?)
              -Erik.
              PS, thank you to the people that posted info in this group that helped
              me track down this problem. -
              

    Erik,
              No need to write a bean, just write a serverlet...
              you can use this function (however you might want to include some
              improved error handeling)
              Oh, FYI to prevent caching by the browser you might want to pass a parameter
              into the creation of the image like timeseconds or (in my case) variable
              text which
              was included into the image produced. (You need not even use the variable in
              the code, the server is not bright enough to tell)
              <IMG SRC=".....MyImageProducer?file=my.jpeg&timesecs=12345134">
              Jay L. Toops
              public boolean httpJpegStreamWriter(BufferedImage ib, HttpServletResponse
              response) {
              try {
              javax.servlet.ServletOutputStream myout = response.getOutputStream();
              byte b[] = new byte[1024];
              response.setContentType("image/jpeg");
              //File file = new File("./myserver/public_html", "testjlt.jpg");
              //FileOutputStream fos = new FileOutputStream(file);
              ByteArrayOutputStream fos = new ByteArrayOutputStream();
              JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fos);
              JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(ib);
              param.setQuality(1.0f,false);
              encoder.setJPEGEncodeParam(param);
              encoder.encode(ib);
              b = fos.toByteArray();
              response.setContentLength(b.length);
              myout.write(b, 0, b.length);
              myout.flush();
              myout.close();
              } catch (Exception e) {
              System.out.println("MY httpJpegStreamWriter Exception\n is :"+
              e.toString());
              return(false);
              return(true);
              Erik Lindquist wrote:
              > This took a little while to figure out so I thought I'd share. After
              > doing some research I was led to the following approach on how to load
              > images from an Oracle database into a JSP:
              >
              > The "main" JSP:
              >
              > <HTML>
              > <head>
              > <title>Image Test</title>
              > </head>
              > <body>
              > <center>
              > hello
              > <P>
              > <img border=0 src="getImage.jsp?filename=2cents.GIF">
              > <P>
              > <img border=0 src="getImage.jsp?filename=dollar.gif">
              > <P>
              > world
              > </body>
              > </HTML>
              >
              > And this is the image getter:
              >
              > <% try {
              > response.setContentType("image/gif");
              > String filename = (String) request.getParameter("filename");
              > java.sql.Connection conn =
              > java.sql.DriverManager.getConnection("jdbc:weblogic:pool:orapool"); //
              > connect to db
              > java.sql.Statement stmt = conn.createStatement();
              > String sql = "select image from testimage where filename = '" +
              > filename + "'";
              > java.sql.ResultSet rs = stmt.executeQuery(sql);
              > if (rs.next()) {
              > byte [] image = rs.getBytes(1);
              > java.io.OutputStream os = response.getOutputStream();
              > os.write(image);
              > os.flush();
              > os.close();
              > }
              > conn.close();
              > }
              > catch (Exception x) { System.out.println(x); }
              > %>
              >
              > The thing to note is that there are no <%@ page import="..." %> or <%@
              > page contentType="..." %> tags - just the single scriptlet. It
              > seems that for every "<%@" the weblogic compiler sees it puts
              > out.print("\r\n"); statements in the generated java source.(???) I
              > don't know much about how browsers work but I think that once it sees
              > flat ascii come at it it treats everything that follows as text/plain
              > which is incorrect for the binary stream that's being sent. Another
              > work around was to set out = null; but that's kind of ugly and might
              > produce server errors. The real fix is to write a bean to handle images
              > which I'll work on next (does anybody have any hints on how to do
              > that?)
              >
              > -Erik.
              >
              > PS, thank you to the people that posted info in this group that helped
              > me track down this problem. -
              

  • 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].

  • Displaying dynamically changing image: a problem with JLabel.

    Hello! I use NetBeans 5.5 and I develop my GUI with Matisse. I'm rather a beginner in developing GUIs with this editor...
    I'd like to display a dynamically changing image. The idea is: GUI shows the image, that is modified as some computations run in a different thread. App will be run on a single machine.
    I'm trying to display the image as a label's icon. The problem is that my app's frame can be resized - and when it is, the label also resizes. When the label is resized, the image should also be resized - the image should always be of the same size as the label. The problem? I noticed, that it works only when I make my app's bigger. When I try to lower its dimensions, the label's dimensions remain the same. Why the label don't make its size smaller?
    My code works as follows: when app's main frame is resize, the panel (the one, that the label is placed in) is also resized. And, since the label is in the panel, it (should) also be resized. So I wrote all the resize-events handlers (therefore I know that the resize event is sent when my app's frame is resized, and when the panel is resized - but the label is resized only when it grows bigger). In this methods I modify the image displayed in the label (I resize the image).
    Or, perhaps, there is some other way to show a (dynamically changing) image with Swing... I chose JLabel, because I didn't want to write my own JComponent. JLabel can display image and that is all I need. The problem is: when the label grows bigger, I create a new, bigger image (icon). Why my label don't get smaller (the resize event isn't even sent)?

    There is no component that dynamically resizes an image. You need to create your own. Something like this:
    JComponent component = new JComponent()
         protected void paintComponent(Graphics g)
              //  Scale image to size of component
              g.drawImage(yourImage, 0, 0, getWidth(), getHeight(), null);
    };

  • How to display  servlet dynamically generated image ?

    Hi,
    How to display servlet dynamically generated image ?
    I have a servlet generating a buffered image in the doGet. I want to display the image in a jsp page with other information. I'm not able to get it properly displayed.
    **Try n# 1 **************************************************************
    This displays my image but nothing elle :
    ServletOutputStream sos = pResponse.getOutputStream();
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(sos);
    encoder.encode(img);
    **Try n# 2 ****************************************************************
    I tried also :
    In the servlet :
         request.setAttribute("renderedImage", img);
    and in the jsp page :
         BufferedImage image = (BufferedImage) request.getAttribute("renderedImage");
         <img src="<%=ImageIO.write(image,"jpeg",response.getOutputStream())%>" width="300" height="280"/>
    This last try draws big crap in the jsp page, thank you in advance.
    Nelson

    Call another servlet from the IMG tag. Have the servlet stream out the image using ImageIO (instead of writing HTML).

  • 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

  • Any way for one VI to dynamically update images shown in another VI's Image Display control?

    I've just discovered (in LV v7.0) that, while I can wire to it, I cannot write image data to a "value" input terminal of a property node associated with an Image Display. When the VI runs I get this error:
    "IMAQ Vision: (Hex 0xBFF6051A) The Image Display control does not support writing this property node."
    (I must admit that I have to wonder why we are allowed to wire to it, if all it does is generate this error)
    Is there any way for one VI to dynamically update images shown in another VI's Image Display control?
    I am not interested in using IMAQWindDraw windows.

    OK, I have found one way to simultaneously access one VI's image data within another VI without the use of globals. I don't know if it makes use of a known feature of image data that will be with us forever or if it is a bug that will disappear sometime in the future...
    It seems that if I create an image data stream in one VI using IMAQ CREATE and name the data stream "ABC" and then create an image data stream in another VI using IMAQ CREATE and also name that data stream "ABC" then in fact they are both the same data streams and they can be read or written by either VI.
    Using this feature I can write the common data stream in one VI and using a shared occurrence or semaphore let the other VI know when it is OK to display the data from the common stream.
    This method requires that the displaying VI needs to have a while loop around the image display which is not nearly as simple as a display that is updated automagically by another VI writing to a VALUE input that is referenced back to the Image Display. I'd still like to know if there is some way to make that work.
    One corollary to this is that if you have several image data streams in use in a system (they can be in totally separate VI's, running independently) and you don't want them tromping on each other's image data then you need to make sure that they (the image data streams) get created with different names. An example of a place where this might bite you (and where I discovered this "feature") is to have multiple copies of the same VI with different names to do image acquisition and display from multiple cameras. Being copies of the same VI, they all had the same image data stream names, defined as constants, within them. When they were run simultaneously, the image data from all of the multiple cameras randomly appeared in all of the image displays. I don't know if this feature would hold up if the separate VI's were turned into separate executables and then run. Do any of you know if this sharing of image data streams with common names works across executables running on the same machine?

  • Can I dynamically display Page title over a static header image?

    Is there a way to Dynamically Display Page Title Text Over my static site Header Image? here is a link so you can see what I am talking about. http://www.bridgestoprosperity.org/See-Our-Work/afghanistan/afghanistan.htm where Afghanistan would be the text to be replaced automatically on each page.  Please note, currently, I must create individual headers, insert the page title in photoshop, etc. I am hoping to figure out a way for all this to happen dynamically perhaps by calling the text from the page title info.
    Thank you,
    Allan

    Hi, Allan,
    I realize my suggestion is off your point, and you probably have already thought of some of this, hence your question... But, rather than going the dynamic route, Why not create a Header Image without a title on it and use it as a div background image? Replace this
    <img src="/See-Our-Work/afghanistan/Images/header/afghanistan-header.jpg" name="topnavbar_r1_c1" width="779" height="114" border="0" alt="bridges to prosperity: afghanistan">
    with the styled div, for instance:
    <div id="header"><h2>Afghanistan</h2><h3>Bridges to Prosperity: USA</h3><div>
    At this point, you can use a more generic image for the background, one that does not have "Afghanistan" embedded in it, and you may style the #header thus:
    #header {
         width: 779px;
         height: 114px;
         border: 0;
         background-image: url(/See-Our-Work/Images/header/header.jpg;)/* for instance */ 
    and the header Headline styles thus:
    #header h2, #header h3 {
         color: white;
         text-align: right;
         font-family: Arial, Helvetica, sans-serif;
    Then you can place your html (<h2>, <h3> etc.) in the same div, only on the "surface".
    Using the tags <h2> and <h3> will maintain their usefulness to Search Engines; as hiding them in images does not.
    If you still wished to vary the header image, depending on the contents of the page, you can actually control all of this from the CSS file, if you add an id attribute to the <body> of each page.
    For instance, for your example page, if you did this:
    <body id="afghanistan">
    You could then do this in your CSS file:
    #header {
         width: 779px;
         height: 114px;
         border: 0;
    body#afghanistan #header {
         background-image: url(/See-Our-Work/afghanistan/Images/header/afghanistan-header.jpg);
    You could then proceed to have a different background image for each page. (Not your original intention, but now possible).
    <body id="pakistan"> would use a CSS style declaration like:
    body#pakistan #header {
         background-image: url(...pakistan-header.jpg...etc.);
    I am not aware of being able to pass content (other than background images) using CSS, so I would go into each page and put the Headline in html.
    But if you were using multiple background images in the header div (one image for afghanistan, another for pakistan, in my example), you can use the same <body id="afghanistan"> for ALL pages about Afghanistan, and thus have the continuity of the same image for all. Likewise, you could id all pages about Pakistan <body id="pakistan">.
    I hope this gives you some ideas...
    Z

  • How to dynamically display .flv files in website

    I'm using a JSP for my interface.?? In the webpage, I want to pass a java variable, which holds the url to the video that was retrieved from the database, to the flash player script to dynamically determine which video to play.?? For example, this code in the page will play a movie successfully:
    <td><script type="text/javascript">
    AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0','widt h','706','height','633','id','FLVPlayer','src','FLVPlayer_Progressive','flashvars','&MM_Co mponentVersion=1&skinName=Halo_Skin_3&streamName=movies/Video1_1&autoPlay=true&autoRewind= false','quality','high','scale','noscale','name','FLVPlayer','salign','lt','pluginspage',' http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movi e','FLVPlayer_Progressive' ); //end AC code
    </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="706" height="633" id="FLVPlayer">
    ?????????????????????????????? <param name="movie" value="FLVPlayer_Progressive.swf" />
    ?????????????????????????????? <param name="salign" value="lt" />
    ?????????????????????????????? <param name="quality" value="high" />
    ?????????????????????????????? <param name="scale" value="noscale" />
    ?????????????????????????????? <param name="FlashVars" value="&MM_ComponentVersion=1&skinName=Halo_Skin_3&streamName=movies/Video1_1&autoPlay=tr ue&autoRewind=false" />
    ?????????????????????????????? <embed src="FLVPlayer_Progressive.swf" flashvars="&MM_ComponentVersion=1&skinName=Halo_Skin_3&streamName=movies/Video1_1&autoPla y=true&autoRewind=false" quality="high" scale="noscale" width="706" height="633" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" />??????????????????????????
    </object></noscript></td>
    But this code will not play the movie successfully:
    <td><script type="text/javascript">
    AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0','widt h','706','height','633','id','FLVPlayer','src','FLVPlayer_Progressive','flashvars','<%= flashVars %>','quality','high','scale','noscale','name','FLVPlayer','salign','lt','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movi e','FLVPlayer_Progressive' ); //end AC code
    </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="706" height="633" id="FLVPlayer">
    ?????????????????????????????? <param name="movie" value="FLVPlayer_Progressive.swf" />
    ?????????????????????????????? <param name="salign" value="lt" />
    ?????????????????????????????? <param name="quality" value="high" />
    ?????????????????????????????? <param name="scale" value="noscale" />
    ?????????????????????????????? <param name="FlashVars" value="<%= flashVars %>" />
    ?????????????????????????????? <embed src="FLVPlayer_Progressive.swf" flashvars="<%= flashVars %>" quality="high" scale="noscale" width="706" height="633" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" />??????????????????????????
    </object></noscript></td>
    The only difference in the two is that in the second, I use a java variable to set the flash Variables. The variable I use is <%= flashVars %>?? which is equal to: &MM_ComponentVersion=1&skinName=Halo_Skin_3&streamName=movies/Video2&autoPlay=false&autoRe wind=false
    When I view the resulting page source code after building and running the site, The source code is exactly the same for both of them yet one works and one doesn't.?? Any help would be greatly appreciated!

    I've been searching google all day to figure this one out.  I'm not simply trying to play a video, I can already do that... I'm retrieving the location of the video from the database and trying to pass it as an argument to the player, no different than if I was dynamically displaying an image or some text. For some reason I'm not able to do this.

  • 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.

  • Display image on jsp page

    I have to display image on jsp page with some text output. This image is already saved at a location parallel to web-inf and is generated dynamically using a servlet. I have used img tag html to display the image. Other outputs are taking their values from database.
    First problem is that image will be taking time to display in comparision of other outouts from database. I have to refresh the page to get imageon my page.
    Second is that if I save image in a folder parallel to web-inf in my project then it will not be displaying the image.
    Can I use any jsp functionality to display image with other outputs from database. I have used "*include*". but it shows only that image and other outputs.

    Best way is to use a servlet for this.
    <img src="path/to/imageservlet?id=someidentifier">
    <!-- or -->
    <img src="path/to/imageservlet/someidentifier">In the servlet's doGet() just write code which gets an InputStream of the image (either directly generated, or just read from the local disk file system, if necessary with help of ServletContext#getRealPath(), or even from the DB by ResultSet#getBinaryStream()) and writes it to the OutputStream of the response. That's basically all. Don't forget to buffer the streams properly to speedup performance and to save memory.
    You can find here a basic example: [http://balusc.blogspot.com/2007/04/imageservlet.html].

  • I am not able to display image

    Hi..........
    I am showing tiff image on web page i used AlternaTIFF plug ins to display image. I embed the image on web page by using embed tag. like....
    <embed src="file.TIF" width="981" height="444" align="middle" access=94 fit = "100%" mousemode="pan" alt="" name="Image" > </embed>
    It will work fine and show the image.
    But i have to open image as per the selected item in drop down. as i change value in drop down the image will change accordingly....
    I want to make it dynamic any solution please................

    Crosspost: http://forum.java.sun.com/thread.jspa?threadID=5227161&tstart=0
    Please don't crosspost. It's rude and a waste of time and energy for all involved.

  • Displaying images in oracle forms

    I am trying to dynamically display bmp files in an image item. The problem is that the image does not show up if the size of the image item is smaller than the actual image size and also no error is generated. I have tried setting sizing=Adjust and that does not work. Infact if i set sizing =adjust forms never displays the image file.
    help..................

    You are right i just meant to say i am using the read_image_file builtin when i said dynamic. The problem seems to be with displaying the image if sizing is set =adjust. Infact the same application was working with forms 4.5 but is not working anymore after i generated it in forms 60

  • Creating dynamically a image.. with background

    Hi, i'm working on displaying dynamically an image file who shows some text and a rectangular. I want to enhance this method by passing an existing image file, so that this file can used as a background upon creating the gif.
    Example: text = hello, rect = blue line and background = 'back.gif'
    Result : an image file who consist out of the background, the text and the rectangular.
    Is this possible, and could you get me started?
    thx

    I'm not sure how this question relates to the J2EE SDK. Perhaps you can look at tools that can be used to construct GIFs dynamically. In the past I have used a tool called GIFs on the fly to create dynamic GIFs.

  • Can a display image field be changed with javascript

    I have a select list (P3_RECON_CONDITION). when it changes It triggers javascript..
    in that javascript I would like it to change a Display Image field (P3_RECON_COLOR) without having to refresh the whole page..
    P3_RECON_COLOR is a Display image filed that gets its image from a blob from SQL:
    select color from projstat.condition_color, projstat.project where condition_color.condition = nvl(:P3_RECON_CONDITION,'W') and project.job_piece = :P3_JOB_PIECE
    the display field works now, but only for what the P3_RECON_CONDITION is when the page is loaded..

    yes, I tried that, but couldn't figure out how to do the: " dynamic action refresh the item P3_RECON_COLOR"
    I have
    Event: Change
    Selection Type: Item
    Item: P3_RECON_CONDITION (the select list)
    no condition
    TRUE ACTION: Refresh
    Fire when True:
    Selection Type: Item
    Item: P3_RECON_COLOR (the display image)
    (if I change the action to submit page.. it does fire.. but the refresh item does nothing..)

Maybe you are looking for