Opening a MS Word file in Browser.

Hi! Friends....
I am trying to open a Ms Word file in a java prog. What actully i am doing is that i am opening the file using JSP.
I am creating a blank file using
new File();Then i am setting its content type
setContent type('application/msword');seting its default encoding
setEncoding('UTF-8')It is opening the file.But asking in which application to use.And thenasking which encoding type to use to open.
I want that it should open that directly in Ms word and should not ask the encoding type to open for.
Please suggest me some thing.
Thanks and Regards

You shouldn't be doing that in a JSP. Some widely used webbrowser developed by a team in Redmond would look at the URL (which ends at .jsp, is it?) rather than the headers.
Use a Servlet for that which takes the file name as part of the request URL. You may find this article useful: [http://balusc.blogspot.com/2007/07/fileservlet.html]. Just change the content disposition to 'inline'.
Jamwa wrote:
Put the following in the body of your jsp:
<%
response.setHeader("Content-disposition", "attachment; filename=myFile.doc");
%>
That won't open the file directly. That would pop up a 'save as' dialogue.

Similar Messages

  • Which lib to open and view office file on browser

    Hi all,
    when I receive a stream of file from server. How I can open and view this file on browser?
    My suggest: catch a stream and use library to open office file on browser, but I don't know which lib to do this.
    Thanks

    I'm confused, you're coding for the server-side, with JSP/servlets aren't you? So how can you intercept the stream at the browser? That'll be beyond your code.
    And anyway, if you set the MIME types and set the content for the response, the browser itself will decide and prompt the user for handling the file.
    If on the other hand, you want to open a file on the server and send the contents of that to the browser, you can look into Apache POI (http://poi.apache.org/) for handling Excel, Word and PowerPoint documents.

  • Open And Edit Word File In SharePoint Site Programmatically (Without Save On Local system)

    Hi Sir ,
             I am working as sharepoint developer. I have face some problem in Edit and open document file in sharepoint site programmatically. I want to open file and edit directly in sahrepoint site without save in local system,
         Issue:   I have upload one doc file then try to edit and open but In that case file is dowanload and save in local save.

    Hello,
    As i understand you want to open and update word file. Please have a look at below links:
    http://mysharepointwork.blogspot.ca/2010/06/programmatically-open-and-save.html
    http://howtosharepoint.blogspot.ca/2010/05/programmatically-edit-and-save-file.html
    It is good place to start.
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Can't open Excel or Word files on share drive (SMB or AFP) after 10.9.2

    After updating to Mavericks OS 10.9.2, I can no longer open excel or word files on my company file share.  I receive the error:
    'FILEPATH' could not be found.
    Ckeck the spelling of the file name, and verify that the file location is correct.
    If you are trying to open the file from your list of most frequently used files on the File menu, make sure that the file has not been renamed, moved, or deleted.
    I am able to open files on my lcaol hard drive, and other external USB Flash drives.  Word present's a slightly different error, with the same theme (filename).
    I've tried rebooting both the client and server (both running 10.9.2).  Was successful opening files when booting the client into safe mode.  Any ideas?
    Bill

    I don't know if this will help but I had a similar problem that started yesterday. I have two macs.  Once can't open MS Office files from the other Mac but can open Office files on each Mac. Drove me nuts for about 2 hours today - on the phone with Apple twice and Microsoft once.  Finally found a similar post from 2007 that suggested to turn off and on file sharing by unchecking the "Share files and folders using AFP", on both computers and rebooting. That fixed it. 
    Funny thing, it was only with Office files I created since updating the software last week. Old Office files opened fine. 

  • How to open a seperate Word File through a button in WDA?

    I try to embed a world fine inside my WDA-View, but some necessary functions are deactivated.  (see [my question|A question about the SAP Demo Example: OfficeControl in WebDynpro ABAP; )
    So now I try another way to open a separate Word File through a button. Do you know any suggestions?
    Many thanks!

    Thanks a lot for the quick replies!
    Now I can open a Word file. But the content is not connected. Do you know what's the problem? The codes are as following:
    METHOD onactionopen_wordfile .
      DATA : mime_repository TYPE REF TO if_mr_api,
      content TYPE xstring,
      url TYPE string VALUE 'D:\YWU\LernenMaterial\bingen\Web Dynpro\HelloWorld.doc',
      lv_fnam TYPE string..
      mime_repository = cl_mime_repository_api=>get_api( ).
    get the content of the word file
      CALL METHOD mime_repository->get
        EXPORTING
          i_url              = url
          i_check_authority  = ' '
        IMPORTING
          e_content          = content
        EXCEPTIONS
          parameter_missing  = 1
          error_occured      = 2
          not_found          = 3
          permission_failure = 4
          OTHERS             = 5.
      cl_wd_runtime_services=>attach_file_to_response(
      EXPORTING
      i_filename = url
      i_content =  content
      i_mime_type = 'APPLICATION/MSWORD').
    ENDMETHOD.

  • HT6084 Since upgrading to OS X Mavericks I have not been able to work on any MS Word tracked changes documents (works fine if no tracked changes), as every time upon opening such a word file the word processor closes / crashes. What can be done in this ca

    Since upgrading to OS X Mavericks I have not been able to work on any MS Word tracked changes documents (works fine if no tracked changes or comments in the doc). Every time upon opening such a word file with tr.changes the word processor closes / crashes.
    What can be done in this case?

    I just discovered that by turning off in tracked changes balloons in Word preferences prevents the software from crashing, but from then on I need to use only the review pane.

  • How to open an MS-Word-File from a Java-Applikation ?

    Hi,
    i want to open an MS-Word-File from a Java-Applikation.
    Something like this:
    File myFile = new File("myFile.doc");
    myFile.open(); //unfortunately this methode doesn't exist
    Thanks for response

    In my opinion you have to use the Runtime.exec(String) method. I do not know the program name for msword.
    You can open a file in notepad by invoking the method Runtime.getRuntime().exec("notepad c:/xyz/abc.txt");
    Runtime runTime = Runtime.getRuntime();
    runTime.exec("programName" + " " + file);
    Of course the computer on which the program runs must have the application!
    Hope this helps!

  • On iPad can I open a Microsoft word file with apple pages app?

    On iPad, can I open a Microsoft word file with apple pages application?  If so how do I perform this activity?

    Yes you can open Word files. If it is an email attachment you can simply tap and hold down on the icon and select "open in" and then select Pages - as long as you have the Pages app on the iPad.
    Where is the file on your iPad or how do you want to move it to the iPad?

  • How do I open a microsoft word file using Teststand 2010?

    Hi All,
    I am currently using Teststand 2010. I need to do a simple task, at least I thought it was simple. I want to open a microsoft word file using Teststand 2010. I thought the using the "Call Executable" would be the first step, but I am not sure how to set it up. Any help would be greatly appreciated.
    Thanks,
    WJ

    Hello,
    You will actually need to use an ActiveX step to use Microsoft Word. I found this forum post with a similar question and an example. I opened the example and saved it to TestStand 2010 to reattach here.
    Note: you will probably need to modify the "Open Document" step to make sure the FileName of the Word document matches the real file location.
    Taylor B.
    National Instruments
    Attachments:
    TestStand MS Word.zip ‏13 KB

  • Displaying MS Word File in browser

    Hello,
    Can anyone pls tell about the method to display MS word file present in a folder in my site on the browser.
    I dont want it to give it as download dialog box.
    Thanks
    Sharath

    It may still be easier to use Google Documents.
    But if you don't want to do that, I suggest that you check SourceForge or jakarta.apache.org. There's a project called POI that lets you process some Microsoft Office documents in Java (Excel in particular), and there's probably one that deals with Word docs. Someone may have already written a utility that uses that to turn Word into HTML. Then you could tie that into your servlet environment.
    Trying to display the Word file on the user's browser, directly, as a Word file and not processed into something else, is likely to be a tremendous pain in the butt.
    Another thing you could possibly do is convert all your Word documents into HTML or XML or some other more portable format, before you even install them on your server. Make it part of your build/deployment process. It sounds a bit painful, and it might be at first, but doing things at build time is much nicer than doing it at run time.
    Generally, I'd advise moving away from Word format completely, even before build time, if you can possibly get away with it.

  • New MS Word won't open old MS Word files

    We've got a new MacBook Pro, running Lion, with MS Word 2011 for Mac. We've just copied over our old MS Word (Mac) files, with the .doc file ending. I think the files were created in MS Word 2004, some files even ealier than this. The new MS Word 2011 (which we've updated) will open the old files. We have to open the file in Word using "recover text from any file" --- but they loose all their formatting.
    How can we open the files and not loose the formatting?
    Thank you
    Mark

    Sparky Marky wrote:
    That's interesting. How do you do it?
    Are you using Lion? Do you have to open the files within Word (you can't double click on them)? And do you have to open the files within Word by using "recover text from any file" option? I presume your old files have .doc ending, or have you changed this?
    Thanks for any guidance
    Yes using Lion on Mac and both Win 7 Pro and XP Pro on PC hardware. On PCs I have Office 2000 installed, yes even in Win 7 (and Win 8 Preview, Office 2000 installed without a problem). On Mac I have Office 2011 Mac, and all updates.
    As far as the files they are all in a folder called My Documents on both systems. I change/edit or create files on either system then I use a Sync program to sync the My Docs folder between all PCs and Mac. If I'n sitting at one of the PCs and need to open any doc I just open it, word opens and loads the file. Same for if I'm sitting at the Mac. I have Word files that were created on Word 95 (or whatever that was called) Word 98 and now 2000 and Mac 2011.
    Never had any problems. Even if by accident I save a file in the new DOCX format on the Mac. I have the Document converter program installed on the PCs that only have Office 2000 installed.
    Sorry I don't have any real tips for you as mine Just Works, both Windows and Mac.

  • Can't open Read-Only Word Files

    Hi,
    I can't open word files that windoze has arked as Read-Only with pages 08. I get the error message, "the document FILENAME couldnt be opened."
    Anyone got ideas..

    Hi folks,
    I've solved the problem, so if anyone else is having the problem, I solved it this way. The files were on a memory stick, so when I read this: http://docs.info.apple.com/article.html?artnum=106712 it became obvious that if a dragged the files into my Documents folder OS X should give the correct file permissions automatically and it did. Well done Apple.
    The link also gives info on how to do this manually if you need help.
    Dave.

  • Pages will not open some MS Word files!!!! Frustrated

    Hi there,
    This could be something really simple but I am getting really annoyed at it not working. I have Pages 08 and am trying to import documents from Microsoft Word 2003. The documents have .doc extensions, which Apple says are fully supported. I have managed to open a few very simple documents of this type, that contain only one or two words, so I don't think that it is an unsupported version of MS Word. When I try to import files, Pages comes up with this:
    Import Error: The file format is invalid
    The documents are NOT large, only a few kb's.
    Thanks, I really hope someone may be able to help me!!!

    There are such a lot of things that could go wrong in MS Word that it is impossible to tell what goes wrong in yours.
    May I guess that they all come from the same source and perhaps use the same original template? They may have the same author, who uses an unusual kind of logo in the header, which makes Pages choke.
    To get them into Pages, try opening them in another application first and then save them from that application. You could try TextEdit, NeoOffice or AbiWord for example. They are all free and TextEdit is already on your harddisk.

  • Can I open excell and word files on iPad

    Is there a way to read ms office files ag. Word , excel or PowerPoint on I pad?

    The iPad will open and display them natively.  To edit them, you need an app from the App Store.  Documents to Go is one.

  • I can't open excel or word file. it says excel quit unexpectedly.

    i can't open microsoft excel of word suddenly. message keeps coming that microsoft quit unexpectedly. pls help

    Is the version of excel from Office 2004 or older?
    That will not run beyond 10.6.8, because it contains PowerPC code, no longer supported in 10.7 and later.

Maybe you are looking for