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

Similar Messages

  • Display image in JSP Portlet

    I create a JSP portlet. But The portlet can't display image(gif file, jpg file). I have modified the provider.xml and the following line is added:
    <imageURL>URL_Path</imageURL>
    But, the image still cannot be displayed.
    How can I display image in JSP portlet?

    Leo Cheung,
    You could try the following :
    1. Add a virtual directory path Alias 'imgf' in the Apache configuration file httpd.conf to load the image file. Add the following line under the alias section :
    Alias /imgf/ "<your directory>\images/"
    2. Place your gif/jpg files (eg., work.gif) in the images directory.
    3. Use the IMG tag of HTML :
    <IMG src="/imgf/work.gif" border=0 width=80 height=80> in the JSP file at the location where you need to display the image.
    Hope this helps
    Pushkala

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

  • How can I display images that are not included in any collection?

    How can I display images that are not included in any collection (some filter or smart collection)? A smart collection with parameters "Collection - contains - empty field" does not work. Lightroom 5.

    Thank you! Good idea! I ordered letters of the alphabet (space separated), and it works.

  • How can I display images in drop down.

    Hi All,
    How can I display images in drop down.
    <select><option>image here</option></select>
    please reply soon.
    anser please
    Thanks

    I have not found html forum..That's just incredible.
    where can i find it ?Sorry, I'm still recovering from that remark.
    please reply soonEvery time you end a post with this, or "urgent" or other such keywords, the forum automatically introduces a 5 minute delay so that will actually make the whole process slower (not faster).

  • How can i display image in RTF template when Oracle Apps running in Windows

    Can any body help how can i display image in RTF template when oracle apps running in Windows Server.
    Thanks
    Ravi

    Hi Ravi,
    You can add images into your rtf template using MS Word Insert Picture feature.
    Did you try this method?
    Thanks
    Ravi
    [email protected]

  • Dynamically output image in JSP?

    Hi,
    This is a fairly simple action in VBScript, but I can't get it working here in JSP.
    For a database db, i want to cycle through db rows and read the information, and depending on the information in db, different images are populated.
    so far i tried to just dynamically printing out images by wrap <jsp:scriptlet> or just <script> around the <ui:image> but it keeps on giving me errors.
    Could someone please point out the obvious thing that i am missing?
    And how would I iterate through the database rows in jsp?
    appreciate you help.

    I display images dynamically in my application based on Spring and using JSC. Take a look at this tutorial to see what I did: http://swforum.sun.com/jive/thread.jspa?threadID=52657&tstart=0
    In short, I use servlets to read the data, and then set that to the button's image properties. There is a trick to it mentioned in the tutorial I believe).

  • How to upload an image in jsp page

    hi,
    I want to upload an image file with my jsp page, but i cannot do it,
    I have used Jakarta common file upload for this & i have also read following file. But my code isnot working properly? Can you give me any example how to upload an image & how to display it?
    Can u give me any source code? Please help me.
    http://jakarta.apache.org/commons/fileupload/using.htmlwith regards
    Bina

    Hi,
    But after writing the following code i have got following error? What's the problem of this code? please help me?
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    <%@ page import="org.apache.commons.fileupload.*" %>
    <%@ page import ="java.util.*" %>
    <%@ page import ="java.io.*" %>
    </head>
    <body>
    <%
    boolean isMultipart = FileUpload.isMultipartContent(request);
    DiskFileUpload upload = new DiskFileUpload();
    List items = upload.parseRequest(request);
    Iterator iter = items.iterator();
    while (iter.hasNext()) {
    FileItem item = (FileItem) iter.next();
    if (item.isFormField()) {
    String name = item.getFieldName();
    String value = item.getString();
    //ring name= request.getParameter("")
    %>
    <%= name %>:<%= value %>
    <%
    } else {
    %>
    <%
    InputStream stream = item.getInputStream();
    OutputStream bos =
         new FileOutputStream(getServletContext().getRealPath("/images"+"/"+ item.getName()));
    int bytesRead = 0;
    byte[] buffer = new byte[8192];
    while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
    bos.write(buffer, 0, bytesRead);
    bos.close();
    stream.close();
    item.delete();
    %>
    </body>
    </html>Error is:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    FileUpload cannot be resolved
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    DiskFileUpload cannot be resolved to a type
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    DiskFileUpload cannot be resolved to a type
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    FileItem cannot be resolved to a type
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    FileItem cannot be resolved to a type
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    FileUpload cannot be resolved
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    DiskFileUpload cannot be resolved to a type
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    DiskFileUpload cannot be resolved to a type
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    FileItem cannot be resolved to a type
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    FileItem cannot be resolved to a type
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)Please help me.
    With regards
    Bina

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

  • Problem in displaying image on jsp page

    I want to display an image on jsp page.I copied the image the image in WebContent folder.
    I am able to see the image on the design pane when using the following code:-
    <img src="/image.gif" height="50" width="50"> but when i run it in the browser nothing gets diplsyed.
    also when i use the image container and select the source option that image is not displayed in the WebContents file..plz help.

    Hi,
    Seems that the Problem is there with the way how you specifuied the Image relative Path:
    You have specified the below: The opath of image starts with (/) forward slash:
    *<img src="/image.gif" height="50" width="50">*
    It means to access this Image WebLogic Container will form a Path like this:
    http://localhost:7001/image.gif
    BUT may be the image is available inside your Context root: So Change the <Img> tag like following in your JSP:
    *<img src="image.gif" height="50" width="50">*
    (*NOTE:* Never Start your src path with a Preceesing /)
    Now WLE will consider the path like below ..if your Applications Context root is "TestApp"
    http://localhost:7001/TestApp/image.gif
    I am Assuming that Inside the TestApp Application "image.gif" And "your.jsp" jSP pages are Co-Located (Means available in the Same Directory).
    Thanks
    Jay SenSharma
    http://jaysensharma.wordpress.com (WebLogic Magical Stuff)

  • Displaying Image In JSP for Mozilla Browser

    Hai all
    How to display the .gif image in JSP file using Mozilla browser

    do you really think you give enougth information???
    the answer to your question is using the html tag <img src='image_url'>

  • How to resize display image item?

    How to resize an image in display image item not in column?
    I find a way to resize it in column which similar to this way
    decode(nvl(dbms_lob.getlength(PLAYER_PIC),0),0,null,
    '<img style="border: 4px solid #CCC; -moz-border-radius: 4px; -webkit-border-radius:
    4px;" '||
    'src="'||
    apex_util.get_blob_file_src('P5_PLAYER_PIC',ROWID)||
    '" height="75" width="75" alt="Player Image" title="Player Image" />')
    detail_img
    but when I try to implement it to display image item which I returned the image from the column, I cant resize it this way, or may be I used wrong syntax, can you please help me finding way to resize it with steps?

    I guess it is because of some carriage returns in your dynamic img tag that is being generated may be not, so make sure there are no breaks half-way through he attributes of the img tag.
    decode(nvl(dbms_lob.getlength(PLAYER_PIC),0),0,null, '<img style="border: 4px solid #CCC; -moz-border-radius: 4px; -webkit-border-radius: 4px;" '|| 'src="'|| apex_util.get_blob_file_src('P5_PLAYER_PIC',ROWID)|| '" height="75" width="75" alt="Player Image" title="Player Image" />')  detail_imgand also inspect the element/img to see if the code is rendered correctly
    Thanks

  • How can i Display images with may own table

    Hi
    I want display images with my own table. How can I use in this query.
    SELECT    '<a href="#" onclick="javascript:'
           || 'getImageHeight(''my_img'
           || '#ROWNUM#'');javascript:redirect'
           || '(''f?p=&APP_ID.:212'
           || ':&SESSION.:DISPLAY:NO::P212_IMAGE_ID:'
           || ID
           || ''');">'
           || '<img src="#IMAGE_PREFIX#edit.gif" '
           || 'alt="Edit"></a>' ID,
              '<img id="my_img'
           || '#ROWNUM#" src="#WORKSPACE_IMAGES#'
           || filename
           || '"/>' image
      FROM wwv_flow_filesThanks
    Nr
    Edited by: user10966033 on Sep 28, 2009 1:41 PM

    You don't use #workspace_images# since that is for STATIC files, not images in a table..
    see this thread for help: Re: Display image from blob
    Thank you,
    Tony Miller
    Webster, TX

  • How to store/display images with SQL Server 2000

    Hi everybody, I'm totally new to ColdFusion, and creating a
    sample project, where a user would enter in a person's info and
    upload a picture of that person. I trying to get my app to save
    that image to SQL Server database and then to display that pic.
    Currently, it "seems" that I'm able to save to SQL server (my table
    saves user info but all values in my photo column says
    <binary>-I don't know if that is correct), but I can't seem
    to get image and display it on my cf page. I have pasted portions
    of my code below.
    I've been hammering away at this but no luck, so Any comments
    are very well appreciated, example code would be great!
    Thank you so much,
    noijet
    # 1.) I have a 'User Info Entry' page that submits to page
    #2:
    <cfform...>
    <input name="fileToUpload" id="fileToUpload" type="file"
    size="64"/>
    </cfform>
    # 2.) This page does the actual saving, this doesn't output
    any errors but am I saving the image to SQL server correctly? I
    have no idea really how to save images to database, so please
    advise or possibly provide example code. Afterwards, it goes to
    page #3 to display confirmation page that data has been saved.
    <cfif isDefined("Form.fileToUpload") and Form.fileToUpload
    neq "">
    <cfset uploadPath =
    GetDirectoryFromPath(GetBaseTemplatePath()) & "uploads\">
    <cfif not DirectoryExists(uploadPath)>
    <cfdirectory action="create" directory="#uploadPath#">
    </cfif>
    <cffile action="upload" fileField="fileToUpload"
    destination="#uploadPath#" nameConflict="overwrite">
    <cfset imagefile= "uploads\\" & cffile.serverFile
    & "'">
    </cfif>
    <cfquery name="qInsertPerson" dataSource="HRP">
    Execute insertPerson
    N'#Trim(FORM.sLastname)#',N'#Trim(FORM.sFirstname)#',N'#Trim(FORM.sMiddle)#',N'#Trim(FORM .sAlias)#',
    '#imagefile#'
    </cfquery>
    <cflocation url = "savePersonResult.cfm" addToken =
    "No">
    #3.) This confirmation page displays last user entered and a
    picture of the user. The user info retrieved from SQL server is
    displaying correctly but the picture is not displaying(just a small
    red 'x' box). The image calls another getPersonPhoto.cfm file to
    display image.
    <cfquery name="lastPerson" datasource="HRP">
    Exec getLastRow
    </cfquery>
    <cfoutput query="lastPerson">
    #firstName# #middle# #lastName# was added to our Persons
    list. That Person has been given id: #id# <br>
    Thank you for your assistance and cooperation.
    <img src="getPersonPhoto.cfm?id=71" border="0" width="128"
    height="180">
    </cfoutput>
    #4.) This is .cfm file that only displays image of person
    <cfsetting enablecfoutputonly="Yes">
    <cfsetting showdebugoutput="No">
    <cfquery name="getBlob" datasource="HRP">
    SELECT TOP 1 photo FROM Persons WHERE id = 71
    </cfquery>
    <cfheader name="content-disposition"
    value="Inline;filename=ExamplePerson.jpg">
    <cfcontent type="image/jpeg; charset=iso-8859-1">
    <cfoutput>#tostring(tobinary(getBlob.photo))#</cfoutput>
    Note: In my ColdFusion admin, I checked "Enable ... BLOB's"
    and set Blob Buffer to 20000

    Regarding doing the actual saving, here are some other things
    to consider:
    * a max on the image's file size
    * check if it really is an image
    * don't use nameconflict="overwrite". consider
    nameconflict="MAKEUNIQUE"
    * delete uploaded image on file system after insert into db
    Also, on the cfm page that returns an image, try putting the
    cfcontent tag and the cfoutput tag on one line.
    <cfheader name="Content-Type" value="image/jpeg">
    <cfcontent
    type="image/jpeg"><cfoutput>#getBlob.photo#</cfoutput>
    Good luck!

  • Problem for displaying image in jsp

    I like to retrieve and display image from database in jsp file. Now, image has been retrieved and store in session. But it cannot be displayed in jsp. Who can help me? Thanks a lot!
    Codes like below:
    <%
    byte[] b = (byte[])session.getAttribute("sessionName");
    System.out.println(b.length); //the length can be printed at console successfully
    if(b != null) {
    response.setContentType("image/*");
    OutputStream toClient=response.getOutputStream();
    toClient.write(b);
    toClient.flush();
    toClient.close();
    %>

    JSP is designed to return text/html documents.
    As such it automatically calls getWriter() to return a character stream. (places it in the implicit variable "out"
    Seeing as you want to return bytes, instead of character data, the JSP technology is not applicable
    Calling getOutputStream after getWriter has been called results in an IllegalStateException
    So calling getOutputStream in a JSP will ALWAYS throw an exception.
    Cheers,
    evnafets

Maybe you are looking for

  • DVCPro 50 24p @ 29.97 - Pulldown?

    Hello, I'm working on a project that was shot with the Panasonic SDX-900 at 24p. I captured the footage with the DV50 Easy Set-up at 29.97 and I'll be outputting to DVCPro tape as well as DVD. I've read through the forum on how it should be captured

  • Converting XML String to MessageElement array

    Hi, I am trying to call a .NET web service from my Java client. I used WSDL2Java to generate the java classes for calling the .NET web service. The generated classes to call the service expects an array of org.apache.axis.message.MessageElement objec

  • Can't install 121118-12 on global zone

    Hi, after our first round of patching, we're starting again. So, I've had to upgrade my external LPS to latest patches to get it to work at all. It is now on 119788-09 and 121118-12. The patchsvr has been reconfigured to point to getupdates1.sun.com

  • What is the best practice for implementing scheduled tasks in ADF?

    Hi experts, I'm using Jdev 12.1.3, and I'd need your advice in how implement scheduled tasks. We have today a button that generates a Jasper pdf report correctly. The new requirement is to schedule a task that automatically send this pdf via email on

  • MMS messaging problems after jellybean update.

    I am having issues sending and receiving any MMS messages since the update.  If I send one it appears on the phone that it was sent.  I have questioned several people and they do not receive them.  Also I have had several people send me pictures and