Problem in displaying images stored in Blob variable

Hi all,
I have a requirement where i need to retrieve the image stored in Blob variable in DB and display the image in JSP page.
I have written the below code to achieve this, it works fine
In JSP, I am calling a action in the <img tag
<img src='downloadPhoto.page?method=getPhotoInBytes&accessoryModelPictures.id.accessoryNumber=${photo.id.accessoryNumber}/> In my controller class
InputStream inputStream=accessoryPicturesLOB.getPicture().getBinaryStream();
byte[] theBytes = new byte[inputStream.available()];
inputStream.read(theBytes);
response.setContentType("image/jpg");
response.getOutputStream().write(theBytes);But the problem is, *if i right click on the image and select save picture as option i get a error saying "The system cannot find the specified file "*
Can you please tell me what is wrong in my approach/code
Is there any better approach to display image that is store in Blob variable ?
Please help on this.
Thanks in advance.

You need at least to set the filename in the content disposition header.

Similar Messages

  • Display images stored in BLOB in html pages via JSP

    Hello,
    My images are stored in BLOB column of other base than portal.
    in JSP i have to display them in html pages.
    anybody have already did the same thing ?

    teggvb6,
    I believe you should be able to get it to work by doing the grants to the user specified in the DAD (i.e. the user that is logging into Oracle) rather than PUBLIC (someone else may correct me on this?).
    If you're concerned that the procedure could be called by others then I guess you could do some sanity checking within the procedure, for example checking v('APP_USER') or maybe v('SESSION') or perhaps do something clear with the REFERER http header? I haven't thought this through yet but I'm pretty sure you should be able to tie it down a bit more.

  • Displaying images stored in blob columns

    I've seen discussions on how to upload and download blob columns but I want to store a blob in the database and be able to display the blob (which is a jpg) as I would any other <img> on my web page. Instead of having to store the jpg on a file system somewhere, and use the data in the database to formulate a link to the image on the file share, I want to pull it right out of the blob. Does someone have a sample of how to do this? Can I do this?
    Thanks

    Laurence,
    If you uploaded the image via the Application Builder, you can use an image tag like so:
    &lt;img src="#WORKSPACE_IMAGES#my_image.jpg" /&gt;If you followed the upload/download how to, you should be able to reference an image like this:
    &lt;img src="download_my_file?p_file=1232897645" /&gt;Where 1232897645 is the unique ID of the uploaded image. To make referencing images easier, you could write a version of the download_my_file procedure that takes in the name of the image as a parameter.
    Sergio

  • Problem displaying PDF stored in BLOB column

    Hello everyone.
    I've been trying to follow this tutorial http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::p11_question_id:232814159006 on displaying PDFs stored in BLOB columns. This is being performed on Apex 4.2, with my DB running 11g. I've got my procedure, which I'll post below:
    create or replace procedure "PDF" (p_id IN gvo_documents.doc_id%type)
    is
        l_lob    blob;
        l_amt    number default 30;
        l_off   number default 1;
        l_raw   raw(4096);
    begin
        select contents into l_lob
            from gvo_documents
             where doc_id = p_id;
    -- make sure to change this for your type!
        owa_util.mime_header( 'application/pdf' );
        begin
            loop
              dbms_lob.read( l_lob, l_amt, l_off, l_raw );
              htp.prn( utl_raw.cast_to_varchar2( l_raw ) );
              l_off := l_off+l_amt;
              l_amt := 4096;           
        end loop;
            exception
               when no_data_found then
                  NULL;
            end;
    end;
    I am trying to run this through a PL/SQL dynamic region and while I don't receive any error's, the content displayed is a huge mess of garbled text and odd characters. I've tried to run this procedure on numerous other document types, including word files and jpeg images, all with the necessary changes in my procedure, and regardless of what I use, I still get a large mess of strange characters. Does anyone have any information or ideas about why this is happening?

    If I understand correctly, your requirements needs to be broken down into two problems:
    1) click link that pops up a window displaying a new APEX page
    2) an APEX page the displays the document, not downloads it.
    I haven't done #1 (yet).
    However, you may be able to generate a URL that points to the new page as part of the SELECT statement for the Report.
    This has a related question, but no answer yet:
    open pdf in popup browser window
    The key is target="_blank" for the anchor tag.
    To generate the URL, you should use the APEX_UTIL.prepare_URL() function.
    If that doesn't work, a Dynamic Action that does some magical JavaScript stuff may be needed.
    For #2, I lost the URL that showed how to display a PDF as part of a "form" page.
    From what I remember:
    Start with a blank page with one blank HTML region (all the Items go in the HTML region)
    Add an Item for the PK/Doc_ID
    part I forgot Create a Data Manipulation Process
    - Automated Row Fetch
    - On Load - After Header
    - (stuff for your table/view)
    part I forgot Create an (I believe) "File Browser" item type. For Settings:
    - Storage Type "BLOB column specified in Item Source" (and place the column name of the BLOB there)
    - MIME Type Column: (column name) -- since you have multiple types, this is a MUST HAVE
    - Filename Column: (column name) -- I highly recommend you have this.
    - Content Disposition == INLINE <-- this is the kicker
    Also, you will need a Browser Plugin for each of the MIME Types (otherwise, the browser may try to 'download' the file)
    Browsers can handle Image types internally. Adobe's plugin can handle PDFs. I don't know about Word/Excel.
    Again, I don't remember the exact details, but that should cover most of it.
    MK

  • Radio Button group with images stored as BLOB files in database

    Hey all!
    I have radio button group, my idea is that radio button's LOV must display images, I mean BLOB files stored in a table.
    How can I do this?

    Hello Ken,
    I asked similar question in the past, and I believe the answer is still the same.
    Select List as an option of a Radio Group
    In your case, I think you can use a select list with added functionality, like "Select List with Branch to Page" or "Select list with Submit", or you can just attach an onChange event (JavaScript) to each select list. The effect should be similar to a radio group – as soon as the user select one item from any of the select lists, you can fire some action, based on the select list value.
    Hope this can help,
    Arie.

  • 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

  • Displaying images stored in SQL Server

    Is there someway of displaying images stored within SQL
    Server. Is FDS required? Prefer a method to display images without
    using FDS; Web Service would be okay if that can work

    I do that sort of thing using PHP and mySQL the binary part
    of the image is stored in a BLOB field (Binary Large OBject) along
    the rest of the information necessary for the http headers (e.g.
    mime type, file name, file size) being staored in their own fields.
    That info is then used to build the file using PHP. The PHP
    file contains a mySQL query whos result is echoed with the
    appropriate headers. The URL points at the PHP file rather than at
    any saved image.
    Here's the php:
    <?
    # display_imagebank_file.php
    # Note: the ID is passed through the url e.g.
    # this_files_name.php?id=1
    # connect to mysql database
    mysql_connect('HOST', 'USERNAME', 'PASSWORD');
    mysql_select_db('DATABASE');
    # run a query to get the file information
    $query = mysql_query("SELECT FileName, MimeType, FileSize,
    FileContents FROM blobTable WHERE ID='$id'");
    # perform an error check
    if(mysql_num_rows($query)==1){
    $fileName = mysql_result($query,0,0);
    $fileType = mysql_result($query,0,1);
    $fileSize = mysql_result($query,0,2);
    $fileContents = mysql_result($query,0,3);
    header("Content-type: $fileType");
    header("Content-length: $fileSize");
    header("Content-Disposition: inline; filename=$fileName");
    header("Content-Description: from imagebank");
    header("Connection: close");
    echo $fileContents;
    }else{
    $numRows = mysql_num_rows($query);
    echo "File not found <br>";
    echo $numRows;
    echo " is the number of rows returned for id = ";
    echo $ID;
    ?>
    Hope that helps
    Phil

  • Problem with displaying image

    Hello!
    Sorry, I'm a beginner in APEX and have some problems with displaying images in my application. I have read the same topic but unfortunately didnt find the solution.
    So.. I have the interactive report
    table test (
    NAME NOT NULL VARCHAR2(4000)
    ID NUMBER
    BLOB_CONTENT BLOB
    MIME_TYPE VARCHAR2(4000))
    I need to display the column blob_content.
    Thnks a lot.

    1009316 wrote:
    Hello! Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already), and update your forum profile with a real handle instead of "1009316".
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    Sorry, I'm a beginner in APEX and have some problems with displaying images in my application. I have read the same topic but unfortunately didnt find the solution.
    So.. I have the interactive report
    table test (
    NAME NOT NULL VARCHAR2(4000)
    ID NUMBER
    BLOB_CONTENT BLOB
    MIME_TYPE VARCHAR2(4000))
    I need to display the column blob_content.This is described in the documentation: About BLOB Support in Forms and Reports and Display Image. There's an OBE tutorial that followed the introduction of declarative BLOB support in 3.1 as well.

  • Problem in displaying images one by one in JList

    I have a problem in displaying images one by one in Jlist. I want to show 100 images as a thumbnailview in jlist but it is talking too much time to show all the images after scalling 100 images to thumbnail view and making it into ImageIcon. So, i thought that it would be better way to show one by one after scaling it into thumnailview. But my renderer is getting calling after 100 images scaled down and setting into list. I have posted my code 2 days back but there is no reply.
    http://forum.java.sun.com/thread.jspa?threadID=789943
    I donno where i am missing in this code.
    Plz suggest me some solution for it.

    Where is the scaling done? In the ListCellRenderer? Regardless of where that is being done, I assume you are caching the scaled images after you scale them, right? If not, consider adding some sort of caching.
    This should do the trick...
    Rework your ListCellRenderer to check to see if a scaled version of the image is available. If not, start a thread to do the scaling and create an ImageIcon. In the meantime, while that thread is running, have the renderer return some sort of stock icon, like a little generic image icon. When the scaling thread completes, make a call to repaint() on the JList so the cell renderer gets re-asked for the icons. This time around, the renderer should notice that a scaled version (the ImageIcon) is available. Return that. So, this method doesn't guarantee that the images will be produced in order, 1...2...3..., but it will return images as they become available, and the overall JList rendering won't wait until all 100 are ready. If you want them returned in order, just do all of the scaling in a single thread and queue up the images to be scaled, in order.
    I hoped this helps. (If it does, please throw me some Duke Dollars.)

  • Display image stored @ content managemenbt

    Hi,
    this is regarding to displaying image stored @ content management, using <html:img> tag in .jsp
    under a node i am uploading two images. (node having two upload options)
    in .jsp i am using <html:img> tag to display the images.
    i tried to display both the images. But the first image what i upload is not showing. what i upload second is displaying.
    pls let me know how to resolve this.
    Thanks.

    You need to access binary property values separately from the node. In 9.2 the API is accessed via INodeManager.getStream(). Alternatively you can take advantage of the tags we have for this as well. Take a look here on edocs:
    http://e-docs.bea.com/wlp/docs92/cm/developCM.html
    -Ryan

  • Image not displayed programmtically stored in blob column

    Hi,
    I altered student table to store photoes of students. For this I added STIMG as blob, MIMETYPE,FILENAME,IMAGE_LAST_UPDATE COLUMNS to studentadmitted table. Image stored and displayed in report very nicely. With the following query
    select "ROWID",
    "ST_ID",
    "FIRST_NAME",
    "LAST_NAME",
    "FFIRST_NAME",
    "FLAST_NAME",
    "COURSE_ID",
    "SESSION_ID",
    "CONTACT#" "CONTACT_H",nvl(dbms_lob.getlength(STIMG),0) IMAGE
    from "#OWNER#"."STUDENTADMITTED"
    Images are displayed in column but they have different sizes.
    To control this I modified the query like this
    select "ROWID",
    "ST_ID",
    "FIRST_NAME",
    "LAST_NAME",
    "FFIRST_NAME",
    "FLAST_NAME",
    "COURSE_ID",
    "SESSION_ID",
    "CONTACT#" "CONTACT_H",decode(nvl(dbms_lob.getlength(stimg),0),0,null,
    '<img style="border: 4px solid #CCC; -moz-border-radius: 4px; -webkit-border-radius: 4px;" '||
    'src="'||
    apex_util.get_blob_file_src('P16_stIMG',st_id)||
    '" height="75" width="75" alt="Product Image" title="Product Image" />')
    detail_img
    from "#OWNER#"."STUDENTADMITTED"
    Report did'nt run with following error,
    report error:ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    Win Server 2008
    Oracle Database :11G R2
    Apex Ver :4.2
    Sajjad

    Sajjad wrote:
    I altered student table to store photoes of students. For this I added STIMG as blob, MIMETYPE,FILENAME,IMAGE_LAST_UPDATE COLUMNS to studentadmitted table. Image stored and displayed in report very nicely. With the following query
    select "ROWID",
    "ST_ID",
    "FIRST_NAME",
    "LAST_NAME",
    "FFIRST_NAME",
    "FLAST_NAME",
    "COURSE_ID",
    "SESSION_ID",
    "CONTACT#" "CONTACT_H",nvl(dbms_lob.getlength(STIMG),0) IMAGE
    from "#OWNER#"."STUDENTADMITTED"
    Images are displayed in column but they have different sizes.Stick to declarative BLOB images as above. They can be resized in reports using CSS. Add a style sheet in the page Inline CSS property:
    td[headers="IMAGE"] img {
      display: block;
      width: 75px;
      border: 1px solid #999;
      padding: 6px;
      background: #f6f6f6;
    }where the <tt>IMAGE</tt> value in the attribute selector is the table header ID of the image column. Setting only one dimension (in this case the width) scales the image with the correct aspect ratio. (The border, padding and background properties are just eye candy...)
    However, if the original images are large then scaling them in the browser this way is a huge waste of bandwidth and produces poorer quality images than creating proper scaled down versions using image tools. Downloading megapixel images and then reducing them to thumbnail size results in pointlessly pushing millions of bytes that will never be seen.
    For improved performance and image quality, and where you require image-specific scaling the best approach is to use the database ORDImage object to produce thumbnail and preview versions automatically. Note that this is not possible in Oracle XE as Multimedia is not included

  • Displaying the image stored in Blob column

    Hi all,
    I'm trying to print the report with an image. I've stored the image in a Blob column and the format of the image is Jpg.
    I'm using the Reports 10g(10.1.2.0.2). When I'm trying to print the report, I'm getting an error Rep-62203. I want to know whether there are any settings which i need to set to display the image item. I mean to say that are there any registry settings.
    Regards,
    Alok Dubey
    Edited by: Alok Dubey on Dec 1, 2008 12:55 PM

    Hi all,
    I'm trying to print the report with an image. I've stored the image in a Blob column and the format of the image is Jpg.
    I'm using the Reports 10g(10.1.2.0.2). When I'm trying to print the report, I'm getting an error Rep-62203. I want to know whether there are any settings which i need to set to display the image item. I mean to say that are there any registry settings.
    Regards,
    Alok Dubey
    Edited by: Alok Dubey on Dec 1, 2008 12:55 PM

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

  • Problems displaying images stored in SQL Server as Datatype "image"

    I am trying to display an Image stored in SQL Server as
    datatype
    'image' and it only shows a portion of the image.
    It seems to be tied to the size (kb) of the image since the
    larger the
    image the less of it is shown before it cuts off(sometimes it
    cuts off
    mid line so it's about the file size and not fitting the
    image on the
    screen).
    Here is the code I am using that deals with the image.
    [Bindable]
    public var theImage:ByteArray = new ByteArray;
    private function getScans_result(event:ResultEvent):void{
    var imageByteArray:ByteArray = event.result[0].Image;
    theImage = imageByteArray
    <mx:Image id="theIMG" width="160" height="220"
    source="{theImage}"/>
    Any Thoughts??

    I do that sort of thing using PHP and mySQL the binary part
    of the image is stored in a BLOB field (Binary Large OBject) along
    the rest of the information necessary for the http headers (e.g.
    mime type, file name, file size) being staored in their own fields.
    That info is then used to build the file using PHP. The PHP
    file contains a mySQL query whos result is echoed with the
    appropriate headers. The URL points at the PHP file rather than at
    any saved image.
    Here's the php:
    <?
    # display_imagebank_file.php
    # Note: the ID is passed through the url e.g.
    # this_files_name.php?id=1
    # connect to mysql database
    mysql_connect('HOST', 'USERNAME', 'PASSWORD');
    mysql_select_db('DATABASE');
    # run a query to get the file information
    $query = mysql_query("SELECT FileName, MimeType, FileSize,
    FileContents FROM blobTable WHERE ID='$id'");
    # perform an error check
    if(mysql_num_rows($query)==1){
    $fileName = mysql_result($query,0,0);
    $fileType = mysql_result($query,0,1);
    $fileSize = mysql_result($query,0,2);
    $fileContents = mysql_result($query,0,3);
    header("Content-type: $fileType");
    header("Content-length: $fileSize");
    header("Content-Disposition: inline; filename=$fileName");
    header("Content-Description: from imagebank");
    header("Connection: close");
    echo $fileContents;
    }else{
    $numRows = mysql_num_rows($query);
    echo "File not found <br>";
    echo $numRows;
    echo " is the number of rows returned for id = ";
    echo $ID;
    ?>
    Hope that helps
    Phil

  • Inserting images stored as BLOB in table to Oracle Report(10G)

    We have some oracle reports(rdf) built in Oracle 10g. Now we are planning to update these reports to include images stored as pdf's on file system. We have loaded these pdf's as blob into tables. Is there a way to include these image/s into the reports.
    Thx.

    Easy answer: No, this is not possible. You can't show a PDF inside your report.
    Since you are talking about just images, why do you even store these images as PDF? Why not as JPG or PNG (if you need best image-quality)?
    Using a normal image in a report would be no problem at all.
    Complex answer: Yes, this could be possible with an enormous effort.
    You could write yourself a Java-Bean which reads the BLOB, uses something like "iText" to convert the PDF to a normal image, and then display this image.
    I want to recommend to not use this solution since it introduces a really big complexity into you report where the usual solution of just storing images as images and not PDFs would give you a better result (and way better performance).
    Regards
    Markus

Maybe you are looking for