Streaming of files (doc/pdf/xls)

hi,
          i try to stream a file like this:
          FileInputStream fileIn = new FileInputStream("d:\\test.doc");
          int length = fileIn.available();
          byte[] b = new byte[length];
          fileIn.read(b, 0, length);
          ServletOutputStream op = response.getOutputStream();
          response.setContentType("application/msword");
          op.write(b, 0, length);
          when I do this in WLS 5.1 SP5 ....MS-Word do open...BUT...
          there are lots of weird characters in the document....!!!
          (the same problem for pdf:s)
          Browser used is IE5.0
          (the code above works fine in another appserver i've tested)
          I'm I missing some HTTP-headers ???
          thanks for any suggestions!
          regards,
          /goran knutas
          

thanks for your comment,
          but the code-snippet works fine in Orion Webapp server...
          but NOT in WLS 5.1 sp5...that is a bit strange....
          I dont think it has something to do with MS-Word as such...
          though i have noticed that WLS starts every processed page with a lot of
          empty rows..wich is sent to the cliennt...that could be interpreted
          by the Application/Word to be something else...??? or ???
          /goran
          Joe Trung <[email protected]> skrev i
          diskussionsgruppsmeddelandet:[email protected]...
          >
          > Hi Goran,
          >
          > Your codes look great but they won't work due to the internal processing
          of word processors (Adobe or MS winword). The browser depends on
          informations to invoke or to execute the content. Why so complicated? If you
          save a MS doc as a webpage you may see complicated things you couldn't
          imagine. Try the simple way what I did:
          >
          > ejb-2_0-pd2-spec
          >
          > workshop
          >
          > You get on the browser 2 underlined sentences: ejb-2_0-pd2-spec and
          workshop. If you click one of them you get what you expected.
          >
          > Joe
          >
          > "Goran Knutas" <[email protected]> wrote:
          > >hi,
          > >
          > >i try to stream a file like this:
          > >
          > > FileInputStream fileIn = new FileInputStream("d:\\test.doc");
          > > int length = fileIn.available();
          > > byte[] b = new byte[length];
          > > fileIn.read(b, 0, length);
          > > ServletOutputStream op = response.getOutputStream();
          > > response.setContentType("application/msword");
          > > op.write(b, 0, length);
          > >
          > >when I do this in WLS 5.1 SP5 ....MS-Word do open...BUT...
          > >there are lots of weird characters in the document....!!!
          > >(the same problem for pdf:s)
          > >Browser used is IE5.0
          > >
          > >(the code above works fine in another appserver i've tested)
          > >
          > >I'm I missing some HTTP-headers ???
          > >thanks for any suggestions!
          > >
          > >regards,
          > >/goran knutas
          > >
          > >
          >
          

Similar Messages

  • Read binary file (DOC, PDF, TIF,...) into SAP with JCO-Server

    Hallo,
    I want to read a binary file (DOC, PRD, TIF,...) within a JCO-Server and transfer this file to SAP.
    In SAP we want to store the file in DMS.
    Next step is to read a file from DMS and store the file external using the JCO-Server.
    My questions are:
    1. How can I upload/download any binary in JAVA
    2. How have I to define the communication tabel between SAP and JCO to transfer the data (string,char, raw) and how long must be a row.
    Maybe any code exsamples ?
    Thanks

    We found the way how to define the tables so we can transfer the data between SAP an Java.

  • Email concurrent output in output file type (.pdf,.xls) to a random address

    Hi,
    I'm new to the forums, I've an issue which I'm not able to resolve. Plz Help!
    Oracle Database: 10g
    Application Server: EBS R12 R6
    I need to send the output(pdf) of a concurrent to a random email address, say "[email protected]". But in the server concurrent output directory($APPLCSF/$APPLOUT) the output file is stored in ".out" format. So I'm not able to find a solution of how to send the output in pdf format.
    Plz Help guyz

    Guyz Plz Help me,
    If even i can send an URL of the concurrent output file in the output format, the purpose would be solved. And also its a better way to go as UTL_MAIL has an attachment limit of 32K.
    Guyz Plz Help, don't hesitate or preserve any portion of your thoughts or comments about this topic.

  • 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

  • To Attach Documents of diff Types(.doc, .pdf) thru Bex Queries to Elements

    Hello,
    The user needs to save the Documents, other than text type(for eg. .doc, .pdf, .xls etc) thru Queries in Bex/Web for the Info-objects etc. in the Query, in the same way as he is able to do thru RSA1->Docuemnts.
    For the moment the user can create/edit Text documents only thru the "Additional Function->Create new Document". How do we give the provision that user can store file of any type.
    Thanks and Regards,
    Sumita

    Hi Sumita,
                I hope this link may help you.
    http://bwexpertonline.com/archive/Volume_02_(2004)/Issue_05_(May)/V2I5A1.cfm?session=
    Thanks and Regards,
    Ravi

  • Converting Ms Office file to PDF online

    Hi,
    In my web app I would like to convert MS Office files(.doc, .ppt, .xls) into PDF's on request through JSP.
    I have seen a few sites which convert uploaded documents to PDF for free online and send the PDF through mail to the user.
    e.g: [www.doc2pdf.net/converter|www.doc2pdf.net/converter]
    How to do something like this?Any Suggestions?
    Thanks in advance.

    Look for a Java API which can read MS Office files and "convert" them into useable/standard Java objects.
    Then look for a Java API which can create PDF files based on info hold in standard Java objects.
    Then do 1 + 1.
    For the first step I can recommend the Apache POI API and for the second one I can recommend iText.

  • New to iPad from android/PC...How can I view PDF, XLS, DOC files when I am not connected to wifi?

    I understand that GoodReader is able to open PDF, XLS, DOC, etc., but is not actually able to edit them. 
    Documents-to-Go can edit them, but will they be stored on my iPad?
    Evernote seems to be able to access them without being connected to wifi, but cannot edit spreadsheets that I am aware of.
    Does anyone have any good suggestions to be able to access documents while in airplane mode?

    GoodReader, Documents to Go, Pages, Numbers can all store documents on the iPad.

  • How do I use the filter to automatically print email and .pdf, .xls, .doc attachments to my default network printer and to other network printers

    I receive sales orders by email. I want to filter some to print on my default network printer and others to print on another network printer. The email body must print as well as txt, .pdf, .xls, .doc attachments.

    You can filter messages to file them to a certain folder, but I don't think you can have Thunderbird to automatically print them.

  • How to load a pdf/xls/swf files in to a adf:popup

    hi
    my requirement is to open a pdf/xls/swf in a popup. howcan i get a poup with pdf/xls/swf files . presently i am using a servlet.I set the content type in the servlet as application/pdf and so on..
    I am getting data as byte stream from the data base.know how to give this bytestream/response object of the servlet to the panel window.
    In a popup i placed panel window.the struture is:
    <af:popup>
    <af:panelwindow>
    </af:panelwindow>
    </af:popup>
    thanks in advance
    Srikanth.V
    Message was edited by:
    user631950

    Hi,
    I have a similar requirement where I need to show the preview of a document in a popup.
    I have a button and I added "af:fileDownloadActionListener" into the button, then I wrote the following code in my bean for the downloadactionlistener:
    public void showPreviewDownloadListener(FacesContext facesContext,
    java.io.OutputStream outputStream) throws IOException{
    DCIteratorBinding agr = getBindingsForDCB().findIteratorBinding("xyz");
    Row row = ag.getRowSetIterator().getCurrentRow();
    String fileName = (String)row.getAttribute("FileName");
    String fileType = (String)row.getAttribute("FileType");
    BlobDomain file = (BlobDomain)row.getAttribute("FileData");
    try {
    InputStream inputStream = file.getBinaryStream();
    byte[] buf = new byte[1024];
    int count;
    while ((count = inputStream.read(buf)) >= 0) {
    outputStream.write(buf, 0, count);
    inputStream.close();
    outputStream.flush();
    outputStream.close();
    file.closeInputStream();
    docPreviewInlineFrame.setSource(fileName);
    //ADFUtils.setEL("#{pageFlowScope.docSource}", "../"+fileName);
    ADFUtils.invokePopup(docPreviewPopup,true);
    catch(IOException ioex) {
    ioex.printStackTrace();
    when I'm clicking my button, all it does is open a popup to view/download the while.
    My own popup (with a dialog and an internalFram in it) does not get invoked at all.
    Also the file that I'm referring is from DB, can anyone also suggest me how to set the source for the inline frame if the file is from DB?
    Thanks in advance,
    Swapna

  • How convert pdf,xls file format into swf

    Hi friends
                   i am making a tool for wducation site and there i need to convert doc xls and pdf file in swf in runtime and show that in container with cropping and panning functionality.so i do it for doc file format but having no idea how to convert .pdf file format and .xls file format into swf.So please guide me how to do it.
    Thanks And Regards
        Vineet Osho

    QuickTime cannot do this of iteslf: you need to add Flip4Mac:
    http://www.telestream.net/flip4mac-wmv/overview.htm

  • Uploading DOC,PDF etc files and sending it to External user

    Hi,
        I m facing problem in sending doc,pdf,excel files to an external user on his personal email id (gmail,yahoo,etc)as an attchmnent.
        While creating Claim ( T code:- CLM1) the user will attach a file and I want to send it to the external Email ID using 'SO_NEW_DOCUMENT_ATT_SEND_API1' .
        Currently I m not been able to find out the location where the file is getting stored.
    Please guide me on that
    Thanks
    Vinit.

    Hello,
    I saw your question and after reading Tamo's blog, here is the answer to your questions:
    1. how you should initialize the outputstream.
    you do not initialize the outputStream, the Weblogic container does that for you, the call response.getOutputStream() returns a ready to use stream.
    2. what should I do with the outputstream after that, I mean how to show to user. do I need another conversion from outputstream to another datatype File forexample.
    you simply flush the output to the client, and the client will render the blob depending on the mimeType. since the output stream writes to the response that is sent back to the client.
    by the way, those two questions has more to do with J2EE than ADF.
    Best Regards,
    Ahmad Al-Zamer

  • I`d like to know how can i insert documents, xls/doc/pdf into iCloud and have them in my iPhone and my iPad. I just found one way, through ibooks, but i think it isn't a practical option.

    I`d like to know how can i insert documents, xls/doc/pdf into iCloud and have them in my iPhone and my iPad. I just found one way, through ibooks, but i think it isn't a practical option.

    Just use Drop Box instead.

  • When I converted a file from PDF to WORD.DOC it opened as Read Only and I'm unable to alter any of the text.  How can I solve this problem?

    When I tried to convert a file from PDF to WORD.DOC it opened as Read Only and I'm unable to alter any of the text.  How do I solve this problem?  I don't know how to change it from Read Only.

    Dear Sara
    Thank you very much for sending the converted file.  Yes, I am able to edit it - that will be very useful to me and I appreciate your help.
    Referring to your previous message when you said you'd converted via Acrobat and not Acrobat.com, I'm converting via Acrobat.com because that's the only option that is shown (how do I convert via Acrobat? - perhaps that would be more successful).  I'm using the Export PDF website, and the OCR is enabled to "Recognize text in English UK".  However, I've just tried converting a different LPA pdf form, this time for Health & Welfare https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/245571/LPA114_He alth_welfare_LPA.pdf and again I have the same problem as before.  I've altered it from "Read only" and thought I'd then be able to enter text, but "Drawing Tools" is shown in the pane and I'm unable to enter anything onto the form - everything appears to be in images.  Also, the lettering on the heading of' page 1 has become jumbled, with the word "Public" overlaying the word "Guardian."  Any suggestions as to what it is I'm doing wrong would be welcome - I don't like to be beaten!
    Regards,
    Judith.

  • How to view pdf, xls files generated by using JasperExport

    I am using Weblogic Server 8.1 to deploy my project. I have some pdf, xls files that generated by JasperExport. Code: <br>
    Map parameters = new HashMap(); <br>parameters.put("donvi",DVi); String ConnectionURL ="jdbc:oracle:thin:@localhost:1521:qltb"; <br>Class.forName("oracle.jdbc.driver.OracleDriver"); <br>Connection jdbcConnection = DriverManager.getConnection(ConnectionURL,"qltb","qltb12345");<br> jasperReport = JasperCompileManager.compileReport("C:\\baocao.jrxml"); <br>jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,jdbcConnection);<br> //JasperViewer.viewReport(jasperPrint); <br>JasperExportManager.exportReportToPdfFile(jasperPrint, "report.pdf");<br>
    report.pdf is exported to folder <br> C:\bea\user_projects\domains\cems ( cems is name of domain) . <br> But I dont know how to view this file or write relative path of this file For example : in test.jsp page I write Report 1 But it doesnt work.

    Install IronTrack SQL as described in the following link
    http://www.irongrid.com/documentation/irontracksql/install.html#install_oracle9iAS

  • Store and Display doc/pdf files in the database using Forms

    Hi all,
    How can i store and display doc/pdf files in the database using Forms 10g?.
    Arif

    How to get up and running with WebUtil 1.06 included with Oracle Developer Suite 10.1.2.0.2 on a win32 platform
    Solution
    Assuming a fresh "Complete" install of Oracle Developer Suite 10.1.2.0.2,
    here are steps to get a small test form running, using WebUtil 1.06.
    Note: [OraHome] is used as an alias for your real oDS ORACLE_HOME.
    Feel free to copy this note to a text editor, and do a global find/replace on
    [OraHome] with your actual value (no trailing slash). Then it is easy to
    copy/paste actual commands to be executed from the note copy.
    1) Download http://prdownloads.sourceforge.net/jacob-project/jacob_18.zip
      and extract to a temporary staging area. Do not attempt to use 1.7 or 1.9.
    2) Copy or move jacob.jar and jacob.dll
      [JacobStage] is the folder where you extracted Jacob, and will end in ...\jacob_18
         cd [JacobStage]
         copy jacob.jar [OraHome]\forms\java\.
         copy jacob.dll [OraHome]\forms\webutil\.
      The Jacob staging area is no longer needed, and may be deleted.
    3) Sign frmwebutil.jar and jacob.jar
      Open a DOS command prompt.
      Add [OraHome]\jdk\bin to the PATH:
         set PATH=[OraHome]\jdk\bin;%PATH%
      Sign the files, and check the output for success:
         [OraHome]\forms\webutil\sign_webutil [OraHome]\forms\java\frmwebutil.jar
         [OraHome]\forms\webutil\sign_webutil [OraHome]\forms\java\jacob.jar
    4) If you already have a schema in your RDBMS which contains the WebUtil stored code,
      you may skip this step. Otherwise,
      Create a schema to hold the WebUtil stored code, and privileges needed to
      connect and create a stored package. Schema name "WEBUTIL" is recommended
      for no reason other than consistency over the user base.
      Open [OraHome]\forms\create_webutil_db.sql in a text editor, and delete or comment
      out the EXIT statement, to be able to see whether the objects were created witout
      errors.
      Start SQL*Plus as SYSTEM, and issue:
         CREATE USER webutil IDENTIFIED BY [password]
         DEFAULT TABLESPACE users
         TEMPORARY TABLESPACE temp;
         GRANT CONNECT, CREATE PROCEDURE, CREATE PUBLIC SYNONYM TO webutil;
         CONNECT webutil/[password]@[connectstring]
         @[OraHome]\forms\create_webutil_db.sql
         -- Inspect SQL*Plus output for errors, and then
         CREATE PUBLIC SYNONYM webutil_db FOR webutil.webutil_db;
      Reconnect as SYSTEM, and issue:
         grant execute on webutil_db to public;
    5) Modify [OraHome]\forms\server\default.env, and append [OraHome]\jdk\jre\lib\rt.jar
      to the CLASSPATH entry.
    6) Start the OC4J instance
    7) Start Forms Builder and connect to a schema in the RDBMS used in step (4).
      Open webutil.pll, do a "Compile ALL" (shift-Control-K), and generate to PLX (Control-T).
      It is important to generate the PLX, to avoid the FRM-40039 discussed in
      Note 303682.1
      If the PLX is not generated, the Webutil.pll library would have to be attached with
      full path information to all forms wishing to use WebUtil. This is NOT recommended.
    8) Create a new FMB.
      Open webutil.olb, and Subclass (not Copy) the Webutil object to the form.
      There is no need to Subclass the WebutilConfig object.
      Attach the Webutil.pll Library, and remove the path.
      Add an ON-LOGON trigger with the code
             NULL;
      to avoid having to connect to an RDBMS (optional).
      Create a new button on a new canvas, with the code
             show_webutil_information (TRUE);
      in a WHEN-BUTTON-PRESSED trigger.
      Compile the FMB to FMX, after doing a Compile-All (Shift-Control-K).
    9) Under Edit->Preferences->Runtime in Forms Builder, click on "Reset to Default" if
      the "Application Server URL" is empty.
      Then append "?config=webutil" at the end, so you end up with a URL of the form
          http://server:port/forms/frmservlet?config=webutil
    10) Run your form.sarah

Maybe you are looking for

  • Error while executing root.sh on second node: Failed 3 to bind listening ..

    (root@slpas20)[oracle/crshome/crs11g/css/admin] /oracle/crshome/crs11g/root.sh Checking to see if Oracle CRS stack is already configured Checking to see if any 9i GSD is up Setting the permissions on OCR backup directory Setting up Network socket dir

  • Need sql query to import from excel sheet

    Hey , i need sql query to import from excel sheet. i work in a company where i need to daily update the data from excel sheet. if i get a shortcut method i ill be very thank full to you guys to reduce my work upto 10 %.

  • Call Bex Workbook from browser through ActiveX or OLE

    Hello. I have to run bex workbook from browser. I found out that I can do it through ActiveX and "SAPBEX.XLA!SAPBEXgetConnection", but I didn't succeed. Can anybody help me out?

  • How can I delete plugins from the "edit with" menu?

    I recently downloaded severals demos and trial versions of numerous softwares and plugins. They have recently expired and I'm wondering how I can delete them from the "edit with" menu. I have so many I forget which are licenced and which are trials t

  • Space bar doesn't seem to work in Flash

    Hey everyone, This sounds quite ridiculous but my space bar doesn't want to work in Flash CS3. I'm a web designer and started recently for a new company. They asked me to include a flash image on one of our websites. When I try to add text to the sta