Display in browser blob files (.doc, .pdf...) stored in the Database

Hi,
I want to display blob file from de DB to the browser, but when I click on the link of the document I want to open, nothing append. If I check the length of the file it is correct. I tried to write it in a directory to see what appends. I can only write txt file. The other files are corrupted.
I did something like in the topik 532271.
Did I do something wrong ? Do I have to write some code in the web.xml ?
Here is my code :
public DataOutputStream showBlob() throws SQLException, IOException{
//it is my class not those from java.io
File file = (File) this.getFiles().getRowData();
FacesContext faces = FacesContext.getCurrentInstance();
HttpServletResponse resp = (HttpServletResponse)faces.getExternalContext().getResponse();
Blob b = file.getBlob();
int len = 0;
InputStream is = b.getBinaryStream();
long length = b.length();
byte[] x = new byte[10240];
resp.setHeader("Content-Disposition","filename=\"" + file.getFileName() + "\"");
resp.setContentType(file.getMimeType().getMime());
resp.setContentLength((int)length);
DataOutputStream o = new DataOutputStream(resp.getOutputStream());
while ( (len = is.read(x)) != -1)
o.write(x, 0, len);
o.flush();
o.close();
is.close();
faces.responseComplete();
return o;
In my xhtml page I have :
<ice:commandLink id="downloadLink"
action="#{managerBean.layoutManager.ediTraining.showBlob}"
value="#{file.fileName}" target="_blank">          
</ice:commandLink>
Thank you for your response.
Edited by: joce77 on Nov 12, 2007 7:39 AM

Hi BalusC,
I did what you explant on this page http://balusc.blogspot.com/2007/07/fileservlet.html whit "FileServlet serving from database".
When I clik on the link I got an empty page with this html code :
<iframe id="history-frame" src="/uniform/xmlhttp/blank" style="z-index: 10000; visibility: hidden; width: 0pt; height: 0pt; position: absolute; opacity: 0.22;" title="Icefaces Redirect" frameborder="0"></iframe>
<script id="dynamic-code" language="javascript"></script>
<script id="focus-code"></script>
<script id="select-code"></script>
<script id="click-code"></script>
<script id="configuration-script" language="javascript">window.session='YXtNt2XZnElULb3t0j_7BQ';
document.getElementById('configuration-script').parentNode.viewIdentifier=1;
if (!window.views) window.views = []; window.views.push(1);
window.configuration = {synchronous: false,redirectURI: null,connection: {context: '/uniform/',timeout: 30000,heartbeat: {interval: 20000,timeout: 3000,retries: 3}}};
</script>
Any idea ?
Thanks

Similar Messages

  • Oracle reports to display PDF/Excel files stored in the Database

    can we use Oracle reports to view/display PDF/Excel files stored in the Database? Thanks Lalitha

    A document stored in the database can be easily retrieved in or via the browser using mod_plsql. Simplified:
    select content, mime_type
    into v_blob, v_mime_type
    from ...
    owa_util.mime_header(nvl(v_mimetype,'application/octet'),false);
    htp.p('Content-length: ' || dbms_lob.getlength(v_blob));
    owa_util.http_header_close;
    wpg_docload.download_file(v_blob);So, the link in your report should point to this database procedure.
    Edited by: InoL on Mar 1, 2011 4:17 PM

  • Best ways to view/display PDF/Excel files stored in the Database

    What are best ways to display/view PDF/Excel files stored in the Database? thanks L

    Thanks tom, sorry let me explain. Currently we have oracle forms screen, using webutil to store/view files into DB. client won't like the interface, they want us to make it more friendly, drag and drop if possible, load multiple files, as possible.. So I am exploring different ways to improve may be java (or jdev/any any other), different screen designs, different features for fileupload/download/view options.

  • Actually PRINT (i.e. spool to a printer) a PDF stored in the DB as a BLOB

    Hi Folks.
    I have got APEX to generate PDF files for me based on a shared components query & report template. These are stored in the database as BLOB.
    Is there a way to send these BLOB PDF files directly to a printer?
    I don't want to have to export the files to the server file system and then have the user manually select them from there for printing. Ideally I want the users to select the documents for printing in the UI and these then get spooled to the printer.
    If anyone has a suggestion/steer for me, I'd love to hear it.
    Many thanks
    Simon.
    Application Express 3.1.1.00.09
    Database 10.2.0.3.0
    BI Publisher 10.1.3.3.2

    Hi Tyler
    OK, here's where I'm at...
    Got SoapUI 2.0.2
    Creating a new project
    Setting initial WSDL to http://xx.xxx.x.xx:9704/xmlpserver/services/PublicReportService?wsdl
    (Real IP substitued with 'x' for security)
    'Create Requests' - Checked
    'Create Project File' - Checked
    When I press 'OK' I get an error message stating...
    "com.eviware.soapui.support.SoapUIException: Error importing wsdl"
    A bit more info.
    If I enter the following into my browser address bar...
    http://xx.xxx.x.xx:9704/xmlpserver/services/PublicReportService
    I get...
    PublicReportService
    Hi there, this is an AXIS service!
    Perhaps there will be a form for invoking the service here...
    And If I enter...
    http://xx.xxx.x.xx:9704/xmlpserver/services/PublicReportService?wsdl
    I get...
    AXIS error
    Sorry, something seems to have gone wrong... here are the details:
    Fault - ; nested exception is:
         oracle.xml.parser.v2.XMLDOMException: Implementation does not support the object requested.
    AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: oracle.xml.parser.v2.XMLDOMException: Implementation does not support the object requested.
    faultActor:
    faultNode:
    faultDetail:
         {http://xml.apache.org/axis/}hostname:xxXXXX
    Am I missing something?
    Kind regards
    Simon.

  • Can Discoverer have link to display documents stored outside the database?

    I posted a message some time ago called "Possible for Discoverer to display BLOB type documents stored in database?" and got great answer.
    Now our customers are asking if it is possible, from Discoverer, to link somehow to a file stored outside the database on the Unix file system and get their computer to display it? Can anyone tell me if this is possible please?
    The only thing I've seen in the documentation that may be related is in Oracle Business Intelligence Discoverer Configuration Guide, section 10.6 List of Discoverer user preferences. It says there that Discoverer preference ProtocolList can be set so that Discoverer hyperlinks can be set to use protocols such as telnet, but the default is HTTP, HTTPS, and FTP.
    THank you in advance if you can help.
    Regards,
    Julie.

    Hi Rod,
    I have tried the second method: "create a Oracle directory pointing to the Unix directory containing the files". I have had success with it, but I'd be grateful if you could advise me if you would have done this the same way as described below:
    I put two Word docs and two text docs called clob_test1.txt, clob_test2.txt, blob_test1.doc, blob_test2 in the Unix directory corresponding to an Oracle directory called 'EIF'. I thought an extrenal table was needed so that Discoverer would have an object to write a queruy against. So I created a file called lob_test_data.txt with the following contents:
    1,01-JAN-2006,text/plain,clob_test1.txt
    2,02-JAN-2006,text/plain,clob_test2.txt
    3,01-JAN-2006,application/msword,blob_test1.doc
    4,02-JAN-2006,application/msword,blob_test2.
    THen I created an external table using the following DDL:
    CREATE TABLE jum_temp_lob_tab (
    file_id NUMBER(10),
    date_content DATE,
    mime_type VARCHAR2(100),
    blob_content BLOB
    ORGANIZATION EXTERNAL
    TYPE ORACLE_LOADER
    DEFAULT DIRECTORY EIF
    ACCESS PARAMETERS
    RECORDS DELIMITED BY NEWLINE
    BADFILE EIF:'lob_tab_%a_%p.bad'
    LOGFILE EIF:'lob_tab_%a_%p.log'
    FIELDS TERMINATED BY ','
    MISSING FIELD VALUES ARE NULL
    file_id CHAR(10),
    date_content CHAR(11) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    mime_type CHAR(100),
    blob_filename CHAR(100)
    COLUMN TRANSFORMS (blob_content FROM LOBFILE (blob_filename) FROM (EIF) BLOB)
    LOCATION ('lob_test_data.txt')
    PARALLEL 2
    REJECT LIMIT UNLIMITED
    then created a Discoverer End User Layer folder against this external table, and used exactly the same technique as we did for downloading the BLOB from the database table (creating a new folder item containing a URL calling a database procedure which calls the Oracle code to download the doc). THis worked, but sometimes my PC didn't seem to know that the Word docs were Word docs and it needed to launch Word. Other times it did manage to do this OK. It always displayed the two .txt files as HTML docs.
    Just wondered if you'd be good enough to critique this approach.
    THank you, Julie.

  • Download of files stored in the database

    I am using FireFox and my users IE. Download of files stored in the database worked for me but not for my users. I recieve a choice of downloading the file or opening it with a full file name and file type. IE users have some strange behaviour - no name of the file and they can only save it to their local drive - some kind of weird microsoft security option. I was searching for it but couldn't find. Anyone here who would know where to search for it?
    Denes Kubicek

    Hello Jens,
    I am using the standard procedure from the manual:
    CREATE OR REPLACE PROCEDURE download_my_file_pr (p_file IN NUMBER)
    AS
    v_mime VARCHAR2 (255);
    v_length NUMBER;
    v_file_name VARCHAR2 (2000);
    lob_loc BLOB;
    BEGIN
    SELECT mime_type, blob_content, NAME, DBMS_LOB.getlength (blob_content)
    INTO v_mime, lob_loc, v_file_name, v_length
    FROM my_file_table
    WHERE ID = p_file;
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    OWA_UTIL.mime_header (NVL (v_mime, 'application/octet'), FALSE);
    -- set the size so the browser knows how much to download
    HTP.p ('Content-length: ' || v_length);
    -- the filename will be used by the browser if the users does a save as
    HTP.p ('Content-Disposition: attachment; filename="' || v_file_name || '"');
    -- close the headers
    OWA_UTIL.http_header_close;
    -- download the BLOB
    wpg_docload.download_file (lob_loc);
    END download_my_file_pr;
    Denes Kubicek

  • Exporting file to pdf from internet, the document its in blank or incomplete

    When i export a file to pdf from internet, the document is in blank or incomplete. Its the same if i donwload in a PC or opening online. The trouble is only in this PC, and i try with diferent browsers.
    I try deleting temporary files, upgrading a latest version of Reader and modifying the security configuration in the browser.
    Any idea?

    Hi da23841142,
    What are you using to export the file to PDF? Or, are you simply downloading a PDF file from the Internet, and then trying to view it in Reader? What version of Reader are you using, and are you on Mac OS or Windows?
    Best,
    Sara

  • If I have a repeating event in iCal, can I attach different docs, pdfs, etc., do the events. I am entering lessonplans and want each date to have an attachment.

    If I have a repeating event in iCal, can I attach different docs, pdfs, etc., do the events. I am entering lessonplans and want each date to have an attachment.

    Yes. As you edit each one, you will get a dialog asking whether you want to change all or just the current one.

  • Hello, I bought the MY BOOK LIVE by WD. I did setup, according to the instructions. I stored video files in Live Book. When I opened up video file, that I stored in the MY BOOK LIVE folder, it didn't play well. It started play slow an frizzed. Please help

    Hello, I bought the MY BOOK LIVE by WD. I did setup, according to the instructions. I stored video files in Live Book. When I opened up video file, that I stored in the MY BOOK LIVE folder, it didn't play well. It started play slow an in a few seconds freezed. Why? How can I fix it?
    I wanted to buy the external hard drive storage, instead they sold me a sever storage and it doesn't work well.
    Should I return it? What shoud I get instead?
    Please help!
    thank you so much!

    Hello, I bought the MY BOOK LIVE by WD. I did setup, according to the instructions. I stored video files in Live Book. When I opened up video file, that I stored in the MY BOOK LIVE folder, it didn't play well. It started play slow an in a few seconds freezed. Why? How can I fix it?
    I wanted to buy the external hard drive storage, instead they sold me a sever storage and it doesn't work well.
    Should I return it? What shoud I get instead?
    Please help!
    thank you so much!

  • Export file to PDF - where is the"background activity" in InDesign CS6?

    Export file to PDF - where is the "background activity" in InDesign CS6?
    i´ve been told that I can solve the problem by clicking in to "background activity", but I cant even find it? Where is it?
    I have never ever had this problem, and I cant do my work now.
    Thank you!

    jaisy wrote:
    i´ve been told that I can solve the problem...
    I have never ever had this problem...
    It would be easier to help if we actually knew what the problem is.

  • Displaying images stored in the database

    Hi,
    I'm saving image files (bmp, jpg, gif) in the database as binary data (I'm using SQL Server). Then, I have to retrieve this file and show the image in a JSP.
    I'm using Struts 1.1, SQLServer and weblogic.
    How can I do this?
    Thanks

    Here is a good starting point:
    http://forum.java.sun.com/thread.jsp?thread=338890&forum=45&message=1391475

  • Where is the value of report repository stored in the database?

    Hi all,
    One of our developers is trying to write a code that would send the output report (pdf)of a process through mail, typical work flow stuff.But the problem is that we are not supposed to hard code the value of report repositiry from where the report has to be picked.can anybody suggest a table in the database from where the value of report repository can be queried.
    we tried using
    select reportrepositorypt from pswebprofile.
    but this doesnt return the correct path. we went to PIA->peopletools->webprofile ->webprofie configuration
    here we updated the value in report repository field and saved it and queried again.
    But this didnt solve our problem.
    Its showing the previous value which is different from the actual report repository path.
    all the servers are in solaris box.
    please suggets.
    Thanks!

    Right now, I am trying to send a PDF (XML Publisher report) as an email to our vendors (it is their ACH Advice).
    What I have done so far is: Created an App Engine, one step to populate a state record with run control information and the second step that runs XML Publisher and creates PDF report(s) which are published to the Report Repository and saved to a file on our network. Now I think I just need to create a third step to recall the PDF(s) and send the PDF(s) out as emails to our vendors.
    I have found that the PDF information from Report Repository is stored in the Database in the CDM_LIST_VW record (this is a view and the main underlying table is CDM_LIST, but this contains what I need for now, so I'm going to try using it first). The Report ID is stored in the CONTENTID field and the Report Description (description shown on the Report Repository -- which in our case contains the email address) is stored in the CONTENT_DESCR field. So I am going to try over the next week to write the logic to query the CDM_LIST_VW for the data needed for the email address and the ReportID to go and grab the file....The hardest part is finding the actual file but I am hoping that I can also find a URL on that table. I'd pull the file from the network, but XML Publisher writes them out into numbered folders where all the PDFs are named the XML Report Defn - thus same name). I have not tried any of this yet, but am hoping I'm on the right path.
    I hope this helped answer your question.
    Good Luck!
    Jennifer

  • How to get values/data stored in the database into a list-item.

    how to get values/data stored in the database into a list-item.
    i tried to make a list item without any values assigned to it...but i got the below error.
    FRM-30191: No list items defined for required poplist.
    or
    FRM-32082: Invalid value for given item type.
    List EMPNO
    Item: EMPNO
    Block: EMP
    Form: MODULE5
    FRM-30085: Unable to adjust form for output.
    then according to some docs, i tried the the following for the trigger
    when-new-form-instance
    declare
         rg_name varchar2(40) := 'emp_rec';
         status number;
         groupid recordgroup;
         it_id item;
    begin
         it_id := Find_Item('empno');
         groupid := create_group_from_query(rg_name, 'select empno from emp');
         status := populate_group(groupid);
         populate_list(it_id, groupid);
    end;
    but yet didnt work... :(
    so how the heck do i get values fetched from the database table into the list item?

    for list items you need to values in the record group, one is the shown value and one is the returned value.
    Check out the online help for the populate_list built-in.
    You'll need something like select ename,ename from emp as the record group query.

  • What else are stored in the database buffer cache?

    What else are stored in the database buffer cache except the data blocks read from datafiles?

    That is a good idea.
    SQL> desc v$BH;
    Name                                                                                                      Null?    Type
    FILE#                                                                                                              NUMBER
    BLOCK#                                                                                                             NUMBER
    CLASS#                                                                                                             NUMBER
    STATUS                                                                                                             VARCHAR2(10)
    XNC                                                                                                                NUMBER
    FORCED_READS                                                                                                       NUMBER
    FORCED_WRITES                                                                                                      NUMBER
    LOCK_ELEMENT_ADDR                                                                                                  RAW(4)
    LOCK_ELEMENT_NAME                                                                                                  NUMBER
    LOCK_ELEMENT_CLASS                                                                                                 NUMBER
    DIRTY                                                                                                              VARCHAR2(1)
    TEMP                                                                                                               VARCHAR2(1)
    PING                                                                                                               VARCHAR2(1)
    STALE                                                                                                              VARCHAR2(1)
    DIRECT                                                                                                             VARCHAR2(1)
    NEW                                                                                                                CHAR(1)
    OBJD                                                                                                               NUMBER
    TS#                                                                                                                NUMBERTEMP      VARCHAR2(1)      Y - temporary block
    PING      VARCHAR2(1)      Y - block pinged
    STALE      VARCHAR2(1)      Y - block is stale
    DIRECT      VARCHAR2(1)      Y - direct block
    My question is what are temporary block and direct block?
    Is it true that some blocks in temp tablespace are stored in the data buffer?

  • Image compressed and stored in the database.

    Hi,
    We have a tiff file stored in the database and then compressed using the following Intermedia Oracle method.
    process ('compressionFormat=FAX4,maxScale=1696 2200'); and save it back in the database.
    This oracle database is 8.1.7.4. The tiff file gets processed when we use TIFF file generated by old scanner but errors out with the TIFF file generated by latest scanners.
    The error I get is ORA 29400 , IMG-00704.
    There is a difference in TIFF version in the outputs generated by two scanners,
    The compression option : TIFF modified G3 in the old one
    while the new one has Lempel-Ziv
    Also, the tiff is loaded and saved fine but the image gets corrupted after the intermedia process method is run.

    Thank you for your reply.  I am glad to find that I did not miss an option.  I was aware that I could move my pictures into some other folder, but you have forgotten the solution that I chose.  That was to go back and use ZoomBrowser, which works to access photos in any folder I choose.  In addition it loads promptly.  I have only spent a brief time using the ImageBrowser but don't recall seeing any enhancements that over ZoomBrwoser.  Perhaps if I was attempting to interface with other software but as a stand-alone product, well perhaps you could enlighten me as to what makes ImageBrowser EX a better product..  Regarding the Accept as Solution: are you implying that Canon restricts their search function to only those responses that the OP marks as accepted?

Maybe you are looking for

  • The File Replication Service cannot replicate d:\sysvol\domain

    i am getting a error in my evetn viewer that says... The File Replication Service cannot replicate d:\sysvol\domain because the pathname of the customer designated staging directory:     d:\sysvol\staging\domain  is not the fully qualified pathname o

  • Setting HTTP request headers

    Who can tell me how to set HTTP request headers,for example ,If-Modified-Since,i only know how to get If-Modified-Since in servlet and use it.

  • PS: Set-ADAccountPassword - Complexity Exception

    I've got problems with setting new passwords via Powershell on Server 2012 R2: Set-ADAccountPassword -Identity testuser48  -OldPassword (ConvertTo-SecureString -AsPlainText "HelloPassword123#" -Force) -NewPassword (ConvertTo-SecureString -AsPlainText

  • Website for learning EJB

    Hi all I want to learn EJB from the beginnging. Suggest me the best site thank you

  • Import cannot be resolved for IPrivate* imports

    Hi All, I got the error "import cannot be resolved for IPrivate* imports'" when I import existing project. And then I close the project, copy files to gen_wdp folder again and open project according to the method in Thread Always getting 'import cann