I cannot display image (read from oracle BLOB field) on browser?

I cannot display image (read from oracle BLOB field) on browser?
Following is my code, someone can give me an advise?
content.htm:
<html>
<h1>this is a test .</h1>
<hr>
<img  src="showcontent.jsp">
</html>showcontent.jsp:
<%@ page import="com.stsc.util.*" %>
<%@ include file="/html/base.jsp" %>
<% 
     STDataSet data = new STDataSet();
//get blob field from database     
     String sql = "SELECT NR FROM ZWTAB WHERE BZH='liqf004' AND ZJH='001'";
     //get the result from database
     ResultSet rs = data.getResult(sql,dbBase);
     if (rs!=null && rs.next()) {
          Blob myBlob = rs.getBlob("NR");
          response.setContentType("image/jpeg");//
          byte[] ba = myBlob.getBytes(1, (int)myBlob.length());
          response.getOutputStream().write(ba);
          response.getOutputStream().flush();
     // close your result set, statement
     data.close();     
%>

Don't use jsp for that, use servlet. because the jsp engine will send a blank lines to outPutStream corresponding to <%@ ...> tags and other contents included in your /html/base.jsp file before sending the image. The result will not be treated as a valid image by the browser.
To test this, type directly showcontent.jsp on your browser, and view it source.
regards

Similar Messages

  • Image from Oracle BLOB is not showing

    Hi all!
    Im trying to use this code:
    <?php
    //... etc
    $sql = oci_parse($c, 'select * from pf2.documents ');
    oci_execute($sql);
    echo "<table width = 200 border = 1 cellspacing=0 cellpadding=0>";
    while ($row = oci_fetch_assoc($sql)) {
    echo "<tr>";
    echo"<td style=background-color:#DDDEEE; align=center>";
    echo $row['SHORTNAME'] ;
    echo"</td>";
    echo"<td style=background-color:#DDDEEE; align=center>";
    print $row['FILENAME'] ->load();
    echo"</td>";
    echo "</tr>";
    echo "</table>";
    //... etc
    ?>
    Here im trying to select and publish an image from Oracle BLOB,
    but in Mozilla Firefox im getting just whong text:
    яШяа�JFIF��`�`��яЫ�C� $.' ",#(7),01444'9=82<.342яЫ�C 2!!22222222222222222222222222222222222222222222222222яА�МЂ"�яД����������� яД�µ���}�!1AQa"q2Ѓ‘Ў#B±БRСр$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzѓ„…†‡€‰Љ’“”•–—�™љўЈ¤Ґ¦§Ё©ЄІіґµ¶·ё№єВГДЕЖЗИЙКТУФХЦЧШЩЪбвгдежзийкстуфхцчшщъяД�������� яД�µ��w�!1AQaq"2ЃB‘Ў±Б #3RрbrС $4б%с
    Please help!
    P.S.: Im using PHP 5.2.10 under Wintel platform,
    Oracle 9.2.0.4,
    create table DOCUMENTS
    DOCID NUMBER(10) not null,
    SHORTNAME VARCHAR2(30) not null,
    FULLNAME VARCHAR2(250) not null,
    FILENAME BLOB not null,
    AUTHOR VARCHAR2(30) not null,
    CREATIONDT DATE not null,
    VERSION VARCHAR2(10) not null
    Edited by: user502299 on 28.09.2009 5:33

    I am having a similiar problem. I have created the image.php file:
    <?
    $query = "select a.image_file FROM officer_image a, officer_info b where a.officer_id=b.officer_id and b.officer_lname like 'LEDEZ%' ";
    $stmt = @OCIParse ($db_conn, $query);
    @OCIExecute($stmt, OCI_DEFAULT);
    @OCIFetchInto($stmt, $arr, OCI_ASSOC+OCI_RETURN_LOBS);
    $result = $arr['BLOB'];
    @OCIFreeStatement($stmt);
    @OCILogoff($conn);
    $im = @imagecreatefromstring ($result);
    if (!$im) {
    $im = imagecreate(150, 30);
    $bgc = imagecolorallocate($im, 255, 255, 255);
    $tc = imagecolorallocate($im, 0, 0, 0);
    imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
    imagestring($im, 1, 5, 5, "", $tc);
    Header("Content-type: image/jpeg");
    Header("Content-Disposition: attachment; filename=filename_".uniqid(time()).".jpg");
    imagejpeg($im,'',100);
    imagedestroy($im);
    ?>
    And then in the actual search web page:
    <?php
              $tname = $_POST['lname'];
              $lname = "{$tname}%";
              $id = "1";
              //$query = "SELECT officer_id, image_file FROM officer_image WHERE ID='.$id.'";
              $query = "select a.image_file FROM officer_image a, officer_info b where a.officer_id=b.officer_id and b.officer_lname like 'LEDEZ%' ";
              //oci_bind_by_name($sql, ":bv", $lname);
              //oci_execute($sql);
              $stid = OCIParse($conn,$query);
              Header("content-type:image/jpeg");
              OCIExecute($stid, OCI_DEFAULT);
              while($succ= OCIFetchInto($stid,$row)) {
                   foreach($row as $item) {
         $blob_message = $item->load();
                   // Output the image
              //imagejpeg($blob_message);
              echo $blob_message . " " ;
              //echo "<img src="image.php?id='.$blob_message.'" border="0">. $rows['officer_id']."\">\n";
              echo "<br /><br />";
                   // Free up memory
              //imagedestroy($im);
              //while ($row = oci_fetch_assoc($sql))
    ?>
    Can anyone help?

  • Cache of Displayed Images Stored in a BLOB

    I would like to know how I can cache the data that is an image stored as a blob? This is for when I refresh/revisit/branch to a page taht contains images sourced from a blob, such that it does not compel the browser to regenerate the blob image file data?

    Hi!
    We use jsp (for example ManagerPhoto.jsp), which is deployed to OC4J:
    Blob managerPhoto;
    response.reset();
    response.setHeader("Content-Disposition", "attachment; filename=manager_photo.jpg");
    response.setHeader("cache-control","public");
    ServletOutputStream outputStream = response.getOutputStream();
    outputStream.write(managerPhoto.getBytes(1, (int)managerPhoto.length()));
    out.clear();
    out = pageContext.pushBody();
    And HTML-code in the page to display an image:
    <img width=120 height=149 src=".../ManagerPhoto.jsp?p_orun_id=11">
    Regards,
    Al.

  • Application designer issue - Cannot display image preview

    Hi guys,
    When I attempt to use an image icon as the label for a pushbutton,
    I receive this message in App Designer:
    "Cannot display image preview.
    The ImgDisplay ActiveX control may not be properly registered. Use the
    Install Workstation functionality of Configuration Manager to register this control"
    Anyone has the same experience on it ?
    Thanks in advance.

    What OS is your workstation running on?
    Which PeopleTools version are you running?
    Are your an administrator on the workstation?
    Did you try Install Workstation from Configuration Manager as stated in the error?

  • VGS-1003: Cannot display image

    Hi All,
    I've JPG images with small size (3 KB TO 5 KB) stored in BLOB database field in a report.
    some of images are shown successfully but others give this error:
    VGS-1003: Cannot display image
    I make horizontal and vertical elasticity to contract and make an PL/SQL on the field:
    IF :ID is not null -- a field in the same group indicates the image is found.
      return true;
    else
      return false;
    end if;
    exception
      when no_data_found then return null;
    but this does not solve the problem. Why this error occurred for some images only and how to solve?
    Note: I'm using Oracle DB 11g R2, Reports 6i

    Hi
    Even I had some problem in displaing the Images which is located somewhere in the defined path of server. I am using Forms 10g.
    I have tried with .BMP file and it worked out.
    I am using the following code in In-New-Form_Instance
    READ_IMAGE_FILE(:GLOBAL.Image_Path ||'test.bmp', 'BMP', 'IMG_TEST');
    Regards
    JC

  • I cannot view images imported from nikon d4

    i cannot view images imported from nikon d4.
    I have just upgraded to the most current version of aperture and when I import images from my qxd card it looks like it is importing but no images show up.

    So the images show up in the Import pane of Aperture but after you press the Import button they do not show in the project you are importing into?
    Does this happen for both Raw and JPG images?

  • Cannot remove adobe reader from IE7 version8

    Please advise I have tried everything!!
    Thanks

    Keep getting
    1606 error.
    Posted previous ( cannot remove adobe reader from IE7 version8 in error)

  • Oracle error ORA-01461when trying to insert into an ORACLE BLOB field

    I am getting Oracle error ‘ORA-01461: can bind a LONG value only  for insert into a LONG column' when trying to insert into an ORACLE BLOB field. The error occurs when trying to insert a large BLOB (JPG), but does not occur when inserting a small (<1K) picture BLOB.(JPG). Any ideas?
    BTW, when using a SQL Server datasource using the same code.... everything works with no problems.
    ORACLE version is 11.2.0.1
    The ORACLE datasource is JDBC using Oracle's JDBC driver ojdbc6.jar v11.2.0.1 (I also have tried ojdbc5.jar v11.2.0.1; ojdbc5.jar v11.2.0.4; and ojdbc6.jar v11.2.0.4 with the same error result.)
    Here is my code:
    <cfset file_mime = Lcase(Right(postedXMLRoot.objname.XmlText, 3))>
    <cfif file_mime EQ 'jpg'><cfset file_mime = 'jpeg'></cfif>
    <cfset file_mime = 'data:image/' & file_mime & ';base64,'>
    <cfset image64 = ImageReadBase64("#file_mime##postedXMLRoot.objbase64.XmlText#")>
    <cfset ramfile = "ram://" & postedXMLRoot.objname.XmlText>
    <cfimage action="write" source="#image64#" destination="#ramfile#" overwrite="true">
    <cffile action="readbinary" file="#ramfile#" variable="image_bin">
    <cffile action="delete" file="#ramfile#">
    <cfquery name="InsertImage" datasource="#datasource#">
    INSERT INTO test_images
    image_blob
    SELECT
    <cfqueryparam value="#image_bin#" cfsqltype="CF_SQL_BLOB">
    FROM          dual
    </cfquery>

    Can't you use "alter index <shema.spatial_index_name> rebuild ONLINE" ? Thanks. I could switch to "rebuild ONLINE" and see if that helps. Are there any potential adverse effects going forward, e.g. significantly longer rebuild than not using the ONLINE keyword, etc? Also wondering if spatial index operations (index type = DOMAIN) obey all the typical things you'd expect with "regular" indexes, e.g. B-TREE, etc.

  • Downloading data from a BLOB Field using mod_plsql

    Hi,
    I am trying to use the mod_plsql to download data from a blob field, I have a web page where I can pick the file name to be downloaded from the documents table This table has the BLOB field that has the Data formatted in a text file format(contains carriage returns), when I open it up in the browser it is displaying it correctly , but when I right click on the file name and choose "Save Target As" and save it as text file it is ignoring the carriage returns and displaying entire blob in one line.
    Can somebody help me figure out why it's not recognizing the carriage returns?
    Any help would be greatly appreciated.
    Thanks

    Hi and welcome to the forum.
    Is there a way to retrieve data from a blob field and save it to temp table.Why would you want to do that?
    Can you provide some more details regarding your requirement?
    (Don't forget to mention your database version as well)
    Also, I wonder why you've added a 'decompress' tag to your question?
    edit, after seeing Tubby's reply
    Dang, the connection must be frozen here ;)
    Edited by: hoek on Jan 6, 2010 9:06 PM

  • Cannot use Adobe Reader to view PDF in web browser error

    I have a new computer and have Acrobat Pro installed.  When I try to click on PDF links in browsers, I get an error:
    Cannot use Adobe Reader to view PDF in web browser.
    I want to be able to open these links using Acrobat Pro.  What can I do in Internet Explorer so I don't always receive these errors, and so pdfs automatically open using Acrobat Pro?
    Steve

    Because it was not designed for Windows 7 doesn't mean it cant run.
    If you install the applications as administrator, you shouldn't have problems. I have installed both Reader and Pro versions on Windows 7 32 and 64 bit without problems, as long as I did it as administrator. You right click on the setup and select Run as Administrator. You don't need to do it for updates if you go through the update option on the help panel.

  • How to read Image data from oracle DB?

    How to read a oracle database object ORDSYS.ORDImage from oracle
    database?
    I can get a oracle.sql.STRUCT object from the database, but i can not
    find the way to convert data to a image object(like oracle.ord.im.OrdImage)
    I had used "OrdImage imgObjj1 =
    (OrdImage)rs.getCustomDatum(1, OrdImage.getFactory());"
    it's a example from oralce.
    But OracleResultSet.getCustomDatum() method is already deprecated,
    i can't find a new method to instead of it.
    Who can help me ? Thank you!
    [email protected]

    More than likely, this is the interface you will use:
    java.sql.Blob
    http://java.sun.com/j2se/1.4/docs/api/java/sql/Blob.html
    Once you get the blob, construct a Raster objects from the Bytes you receive from the blob. Then you can create an Image, ImageIcon, BufferedImage, whatever with the Raster object.
    Good luck!

  • Report to display a picture from a blob column

    hi all
    i have a problem :please help
    environment: oracle AS 10.1.2.0.2 portal version 10.1.4
    i have a slq report:
    select field1,field2...,,
    decode(cd.photo, empty_blob(),
    '<img src="MYCS.show_img?p_field=IMG&p_rowid=NO_CHILD_PIC">',
    decode(cd.SOURCE, 'MAIN',
    '<img src="MYCS.show_img?p_field=CHILD&p_rowid='||mycs_lib.url_encode(cd.rid)||'" width=160 height=120>',
    '<img src="MYCS.show_img?p_field=CHILDARCH&p_rowid='||mycs_lib.url_encode(cd.rid)||'" width=160 height=120>')
    ) "PHOTO"
    from MYCS.mycs_child_details_v cd
    where cd.id like :child_id
    adn ...
    The last field on the (select statement) is a photo(blob type)
    NB:MYCS.mycs_child_details_v is a view
    trying to create the report i get the following Error:
    unable to describe SQL statement. Please correct it (WWV-13010)
    Took exception (WWV-13005)
    ORA-00942: inconsistent datatypes: expected - BLOB wwv-11230
    This report runs without any errors on portal 3.0.9 9i AS
    i dont understand what could be wrong here?
    is BLOB datatype not supported by/on portal?
    is the other way i can display this picture(s)?

    Jean,
    See this thread:
    How can I upload/display image within a record ?
    Sergio

  • Cannot display image

    My Thunderbird version is 31.0. when I receive some email that contain images from my colleague, these images cannot display. but when I copy or move the message to one of my local folders, images can display.
    who can explain this phenomenon for me ?

    Hi coryewhite! In order for our Subject Matter Experts to properly asses your problem, they will need to know a little more about your situation! If you can please respond with the model of your camera and the operating system of your computer (Windows XP/Vista/7/8 or Mac OS 10.x), we’ll be glad to have someone look into it further for you. Thank you!

  • Cannot display images after updating SSL certificate

    Hello All,
    With the changes in SSL certificates (no support for .local domains in public certificates), I had to update the SSL certificate used for our Exchange 2010 Server.  We are a small organization with a single server running Exchange Server 2010. 
    There were some articles about how to change the URL's within Exchange to use the public (not .local) domain names.  We followed these instructions and now, when a user using Outlook sends an e-mail with an image embedded to other users in the domain,
    they see a placeholder for the graphic with the text "The linked image cannot be displayed.  The file may have been moved, renamed, or deleted.  Verify that the link points to the correct file and location." .  This is causing a great
    deal of concern to the users and I cannot find anything on how to fix or even troubleshoot this issue.  Any assistance will be greatly appreciated.
    Thanks in advance,
    Allen
    Long time IT professional always learning the new stuff! Thank you for your assistance.

    Hi,
    According to your post, I understand that client face an problem “The linked image cannot be displayed.  The file may have been moved, renamed, or deleted.  Verify that the link points to the correct file and location” after change SSL certificate.
    If I misunderstand your concern, please do not hesitate to let me know.
    Do you see the "page cannot be displayed" error only from your DC server or also from a Windows 7 client machine? What browser do you use and what version?
    Please run “certutil –store” command from a command to verify that the certificate is correctly installed in the certificate store. Also run “certutil -store my” to check the certificate from CA.
    If the certificate is already installed, please refer to below link to check the value of Cache in registry:
    https://support.microsoft.com/en-us/kb/2753594
    Thanks
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]
    Allen Wang
    TechNet Community Support

  • How to display image returned from servlet?

    Currently: I am getting an image from a database and displaying it using the below code.
    Desired: I want to display HTML also, not just the image.
    response.setContentType("image/jpg");
    ServletOutputStream out = response.getOutputStream();       
    java.io.InputStream in = DatabaseClass.getImageStream(image_name);       
    int bufferSize = 1024;
    byte[] buffer = new byte[bufferSize];
    int length = 0;
    while ((length = in.read(buffer))!=1)
      out.write(buffer,0,length);
    in.close();
    out.flush();
    out.close();I have read about doing this with the image tag (<img src=name.jpg), but this requires storing the image in a file on the server...which is not what I want.
    Any/All suggestions appreaciated. Thanks!

    The <img> tag doesn't necessarily require storing the image on the server. You can just as easily do this:
    <img src="/servlet/imageServlet" width="320" height="240" alt="My image" />

Maybe you are looking for

  • How to Load the Resource Master for Generic Resources by Department?

    We are using P6 enterprise version in our company having a central database. Q1a.) We set the Activities view > Resource Usage Spreadsheet > Select View 1) By Resource OR 2) By Role. The result is the spreadsheet presents the Remaining Early Units by

  • SQL Loader, direct path and indexes on partition tables

    Hi, I have a big partitioned table and I have two indexes on it. When I use SQL Loader to upload data to my table with using OPTIONS (DIRECT=TRUE) UNRECOVERABLE , then it takes almost half hour to load just one record!! When I remove OPTIONS (DIRECT=

  • EOS sales reports in LMS4.0

    HI it's me again:-) I'm trying to generate EoS/EoL reports and reports are empty. so thinking that the download was faulty I have manually downloaded the two ZIP files and copied them in the dedicated directory. rreports were still empty. so I have r

  • Mountain lion download failed

    I tried to download Mountain Lion on my MacBook Pro 3 times and each time it got "stuck" I had it trying for over a half hour each time. I restarted my computer twice. I moved the Mountain Lion icon from the dock into the trash and now that won't eve

  • IPhone 4 Sync Photos Tab

    When I try to sync photos to my iphone 4 it does not sync all of them. On the Sync Photo Tab it says 2511 photos but when I sync it only uploads 80 photos.