Error in  displaying  doc file  on a jsp

Hi
I have an Web appln which retrieves a file stored in the DB. I am using a clob datatype
I have the data stored in an InputStream . When i try to display the file the file contains junk values and the data is not displayed properly . Sometimes i get an error saying that the word document is corrupt
Here is my code :
String fileName = bioFrm.getBiography().getBioFileName();
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
response.setHeader("cache-control", "must-revalidate");
InputStream in = bioFrm.getBiography().getBioFileData();
BufferedReader bf = new BufferedReader(new InputStreamReader(in));
byte[] buf = new byte[1024];
int count;
while ((count = in.read(buf))>= 0) {
     String line = bf.readLine();
     out.write(line);
in.close();
I had tried storing the data in a file array but I do not know how to convert a byte[] into an outpustream. I cannot use response.getOutputStream() bcoz the user should have the functionality to download the file twice which i guess is not possible using response.getOutputStream(). I am using struts so i tried doing the same thing using an Action class but still the file was not getting downloaded correctly . Thanks in advance

I think the problem is in your read loop. Try:
String line = null;
while ((line  = bf.readLine()) != null) {
       out.write(line);
}

Similar Messages

  • How to display Doc file format in the JEditPane?

    At this time , JEditPane supports RTF and HTML file format ,but
    Could anyone tell me how to display DOC file format using JEditPane
    or other JTextComponents?
    Thx a lot!
    Caton

    Hi,
    there is no support for doc files (M$ Word?) in Java. You would have to create your own classes for that eventually subclassing JEditorPane, EditorKit, Document etc. As well you'd need your own reader for the doc format.
    The problem I see with that however is that there is nothing such as thedoc file format. Microsoft just saves anything produced by MS Word into files ending with .doc. But, if there is anything such as a .doc file format, it changes more often than the weather in April.
    Ulrich

  • How do we display .doc files or .pdf files inside flex containers like Panel or Canvas?

    How do we display .doc files or .pdf files inside flex containers like Panel or Canvas? (i am talking about Flex web browser application and NOT air)
    thanks in advance.

    Perhaps I was not clear...
    We have a Word doc.
    We want to create a PDF doc from it.
    We want, in Word/VBA, to add content (annotation/text note=sticky) to the PDF from Word via VBA macro.
    What is the best way to do this?
    1. Use a VBA call to the PDF doc to execute the AcroJS (we would pass the content, location, etc for the note in the call) - what is this VBA call that will execute AcroJS in an PDF doc?
    2. Use AIC OLE objects to access the PDF doc.
    From your last answer - it sounds like I cannot add the annotation to the PDF from the Word VBA macro - is that correct?
    Our content is already in the Word doc - We want to execute a macro in Word that will add content to the PDF doc  - can this not be done in Word?

  • Pages error when opening .doc file

    I've recently installed Snow Leopard, but I'm still using Pages 2/iWork '06.
    Before I installed SL, I had the same version of Pages installed for my own work as well NeoOffice to open any .docs I was sent.
    Although I normally used NeoOffice for those .docs, Pages would still open any .doc file, but would normally not display it correctly.
    Since installed SL, I've also installed Pages, but not NeoOffice. I want to open a .doc file with Pages, but when I try to do so, I get an error message, which reads:
    Pages quit unexpectedly while using SLCompatibility plug-in.
    Click Reopen to open the application again. Click Report to see more detailed information and send a report to Apple.
    If I click 'Reopen', Pages opens, but the .doc file doesn't. If I click 'Ignore' (another button), Pages closes.
    The same error and crash occurs whatever .doc file I try to open. It's not just one file.
    I don't know what SLCompatibility plug-in is, those SL could be Snow Leopard.
    Does anyone know what the problem is and how I can fix it?
    Thanks in advance,
    Jonathan.

    Thanks for the reply.
    I'm running 10.6.2 -- I'm not sure what you mean by 'combo' update, but I updated my new installation of SL yesterday with all the updates that software update could find.
    My Pages is version 2.0.2.
    I deleted the specified file, then repaired permissions, but I'm still having exactly the same problem.
    Some .doc files say:
    Pages quit unexpectedly while using SLCompatibility plug-in.
    Click Reopen to open the application again. Click Report to see more detailed information and send a report to Apple.
    Some others say:
    The document "xxxxxx.doc" couldn't be opened
    Do you have any more ideas what's going wrong?
    EDIT: Should I remove the Arial .tff fonts which have minor problems according to Font Book? I don't know much about Font Book. If I remove them, will I still be able to use Arial? I don't want to permanently delete Arial.
    Thanks,
    Jonathan.
    Message was edited by: j.mercer

  • Error while inserting .doc file into CLOB object in oracle

    hello everybody ,
    i am trying to insert .doc file into clob column in oracle database.i am using oracle 8i. But i am getting error saying
    ORA-01461: can bind a LONG value only for insert into a LONG column
    i have no clue.
    i am pasting code here
    please help me out.
    regards
    darshan
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileReader;
    import java.io.Reader;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    public class InsertingClob {
    public static void main(String[] args) {
    File f = new File("E:\\dar
    sowres.doc");
    int len = (int) f.length();
    System.out.println(len);
    Connection conn = null;
    PreparedStatement ps = null;
    try {
    FileReader fr = new FileReader(f);
    String FILE_INSERT_QUERY = "INSERT INTO RESUMED VALUES(?,?)";
    conn = JDBCUtility.getConnection();
    ps = conn.prepareStatement(FILE_INSERT_QUERY);
    ps.setString(1,"1");
    ps.setCharacterStream(2,fr,len);
    int result = ps.executeUpdate();
    if(result ==1) {
    System.out.println("file has been successfully inserted into the db");;
    }else {
    System.out.println("not inserted");
    }catch (Exception e) {
    e.printStackTrace();
    and the error is
    java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1144)
    at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2152)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2035)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2876)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609)
    at InsertBlob.main(InsertBlob.java:21)
    java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column

    You may have one of a few errors going for you there:
    The error says your column in Oracle is a Long not a CLOB, if it is, then make your column a CLOB.
    CLOB's are not suppored in all environments and/or all interfaces (specifically Windoz ODBC has a problem).
    I believe a DOC (Windoz MS-Word) file is a BLOB, due to formatting characters in the file.
    I had a very similar error using Access and trying to do this, but changing to SAS fixed the problem. It could very well be that your version of ODBC/JDBC drivers does not support it properly.

  • Displaying pdf file in a jsp page...

    hi,
    I want to display a pdf document in a jsp page. i got that pdf file from a servlet class(MVC Architecture) through session. now my problem is to display that pdf file in my jsp page. can anyone give me a idea to solve this problem..

    hi,
    i used that code in scriplets. Actually my problem is I got one pdf file from session and i stored that file in a File object. the code is ..
    File pdfDocument = (File) session.getAttribute(CommonConstants.EBILL_PDF_DOCUMENT);
    now i have to display this pdf file in jsp..

  • Error in displaying PDF file in webdynpro application

    Hi Experts,
    I am trying to display one pdf file using webdynpro abap using MIME.
    While executing the application i am getting an error in the browser:
    " File doesnot begin with '%PDF-' "
    Please help me to proceed.
    Regards,
    Arun.

    Hi Arun,
    Please check this...
    File does not begin with %PDF
    File does not begin with %PDF
    Cheers,
    Kris.

  • Display .doc file in new window by url

    Hi all,
    I hope someone got a quick an easy solution for this one.
    I want to access and display (open/save) a .doc file in a new separate window by using createExternalWindow(docUrl, xxx, xxx), where docUrl is a path on the local webAS. Right now I access the file like this:
    File doc = new File("apps/local/filename.doc");
    wdComponentAPI.getWindowManager().createExternalWindow(doc.getURL(), "", false).open;
    This does not work though, since it gives me the absolute path from the hard drive letter and down, ie: c:/usr/sap/../filename.doc
    We havent installed Office Integration on our webAS.
    Anyone? All help help is appreciated. This doesn't feel like it should be a big issue?!
    Best regards,
    Andreas

    Andreas,
    Here is probably not the optimal and not the most intuitive way to perform this task, but anyway:
    1. In View controller context create attribute with type <b>binary</b>, let us name it <b>MyDoc</b>
    2. In View controller source define private variable
    private ISimpleType _msWordType
    3. In View controller wdDoInit method place the following:
    _msWordType = wdContext
      .getNodeInfo()
        .getAttribute("MyDoc")
          .getModifiableSimpleType();
    ((IWDModifiableBinaryType)_msWordType).setMimeType( WDWebResourceType.DOC );
    ((IWDModifiableBinaryType)_msWordType).setFileName( "MyMsWordDocument.doc" );
    4. Use the following docUrl when calling createExternalWindow
    /* Load document content first */
    final byte[] documentContent = loadDocumentBytes();
    /* And now the trick itself */
    final String docUrl = _msWordType.format( documentContent );
    We successfully apply this technique to display photo from employee profile loaded from database
    VS

  • Cross domain error while displaying .SWF files in  portal

    Hi Experts,
    i am working on EP ,
    i am trying to display a .swf file in a iview but that file is  giving an error as
    Add a cross domain policy file to the external data web server
    this swf file is retriving data from BI system.
    Please suggest !!
    i got a solution of putting a crossdoaim.xml file in root directory but thats not possible

    I think two urls will work for you:
    Xcelsius SWF with QaaWS through SSL: Cannot access external data
    http://livedocs.adobe.com/flex/3/html/help.html?content=security2_04.html

  • Displaying .shp file in a JSP page

    hi all,
    For my application i have to display a map. That one is a .shp file. And it is not a stored one in my system.In that map i have to show a car moving at that particular time, so it will we keep on changing and that one i have to get it from other client every movement and have to display.
    Freinds please tell me how to do that.
    i will be waiting for u.
    thanks in advance
    regards
    srinivas

    I fail to see the relevance with JSP/JSTL
    To read the File I suggest you examine the Java File API
    To render moving grahpics I suggest you examine the Java Graphics classes
    To connect Multiple client I suggest you study Java Sockets, both server and client Sockets.

  • Displaying a file in a JSP

    Hello, I am new to the world of JSP programming. I was wondering if anyone would be able to help me with some advice?
    I need to be able to display the contents of a simple text file on a web page written in JSP and Java.
    I am happy with writing a JAVA program to read a file but my problem comes with how to pass the file content back to the JSP.
    Should I pass the file content back to the JSP in a line at a time or buffer the output into a StringBuffer (for example) and return that to the JSP. Which would be easier or the best way to handle this?
    How do I get the JSP to display the return content.
    Any help or advice happily received.
    Thanks.

    Your problem is not very clearly defined, please give more detail on what you really want to do.
    e.g. where the text file is stored? client side? server side? Is the file created in run time? Is your Java program running in the local machine?

  • Error in displaying web reports converted to jsp

    I have created a JSP page which contains embedded Oracle web reports build using Oracle Report Builder. I am using 10gAS version
    I have deployed the JSP created above to the Oracle Application Server
    but when i try to open the JSP file it gives the following error:
    500 Internal Server Error
    javax.servlet.jsp.JspException: rwlib-1: REP-1202: ORACLE logon not specified. at oracle.reports.jsp.ObjectsTag.doEndTag(ObjectsTag.java:206) at testing.test1._jspService(_test1.java:75) [SRC:/testing/test1.jsp:0] at com.orionserver[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].http.OrionHttpJspPage.service(OrionHttpJspPage.java:56) at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:567) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:302) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65) at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source) at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:604) at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317) at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790) at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.AJPRequestHandler.run(AJPRequestHandler.java:208) at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.AJPRequestHandler.run(AJPRequestHandler.java:125) at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192) at java.lang.Thread.run(Thread.java:534)
    can anybody help regarding this
    this is of high priority to me
    thanks and regards
    Subhajit

    I think the problem is in your read loop. Try:
    String line = null;
    while ((line  = bf.readLine()) != null) {
           out.write(line);
    }

  • Activity management - error when displaying attached files

    Hi Gurus
    we are using CRM 7.0 with the Web user interface. one on my users is getting an error when trying to display a saved attachment in an Activity.
    the error says" No dument display because of missing customising for HTTP service '/default_host/sap/bc/content
    i tried searching on spro to look for customising because on development its working fine, only the Live system is giving an error
    pls help me with the path and also how to fix this error.
    Thank you in advance

    Hi Admire,
    I had the same problem in our development system and used the tips provided in notes 606745 and 685521 to solve this problem.
    Hopes this helps.
    Regards,
    Alex van Vondelen

  • Display uploaded file on JSP page

    Hi All,
    I want to display uploaded file in JSP.
    Initially I am displaying File Name after saving the file & click on edit link.
    i.e on JSP Page I have File Upload component & save button.With that save button I am saving my file to databse.
    So when I click on edit link I am getting that file name from Databse then I am displaying it.
    But now I want to display uploaded file name on JSP page before saving to databse.i.e I will have browse & Upload button.When I click on browse button I will open window from where I will select file.
    This is working fine as,<x:inputFileUpload id="uploadfile" value="#{errorLotBean.file}" storage="file"></x:inputFileUpload>
    But when I click on upload button that uploaded file should be displyed there only.Can anyone please tell me how to do this ?
    Thanks
    Sandip

    Thanks a lot Siefert,
    I tried the way mentioned in URL.
    But what if I want to display all uploaded file on my screen.
    i.e. If user click on browse & select File A then click on upload button.
    (Here the File A will be displayed) with code
    <h:outputtext value="#{benaName.file.name}"
    But what if after displaying File A if user decide to upload another file File B.
    How to display that ?
    with <h:outputtext value="#{benaName.file.name}" its dispalying one file only.
    Thanks
    Sandip

  • How to open a doc file using jsp Anchor tag

    when i am trying to open a doc file using a jsp it is opening with out proper alignment.
              how to open a doc file with proper alignment using Anchor Tag in JSp Page
              

    Hello!
    Does some one of you had open a MS word file (.doc) in Java search for a token like [aToken] replace it with another text and then feed it to a stream of save it?
    I want to build a servlet to open a well formatted and rich on media (images) ms word document search for tokens and replace them with information form a web form.
    Any Ideas?
    Thank you in advanced.

Maybe you are looking for

  • This is a stumper of a problem

    This is quite a specialised problem and i hope someone can help me I am writing a jsp web page to display information from a ldap directory. It works fine except i need to specify where the program is to search the ldap tree. When i specify no locati

  • Help.... trying to set the browser title for reports called from 9i form

    hello all I am attempting to call a 9i report from an oracle 9i form .I am using the following code repid := find_report_object('report5'); SET_REPORT_OBJECT_PROPERTY SET_REPORT_OBJECT_PROPERTY (repid,REPORT_type,CACHE); SET_REPORT_OBJECT_PROPERTY (r

  • SOAP Envelope : Calendar type as parameter

    Dear all, I need to build a SOAP envelope with a parameter defined as Calendar type. But by looking at the encoding : http://schemas.xmlsoap.org/soap/encoding/ I found nothing how to do, any idea? Thanks in advance

  • What is needed to get javac compiler?

    I down loaded and installed jdk-6u6-windows-i586-p.exe. This runs files fine if the compiled .class files are there. When I create a nes .java file and try to compile it using javac, I get errors not recognizing javac command. What do I need to be ab

  • Security Framework in Discoverer

    Hi I am using Discoverer for reporting.And currently we are planning to incorporate security feature using Discoverer.Since I am new to Discoverer,Can anyone please suggest some Security features in Discoverer (any links or document about it.) We hav