Opening word document in a browser

Hi Friends,
I am working on a web application which has a websphere as a web server.
I want to open a word document or any other MIME type file in a browser. I know how to open a word document by setting the content type in a response. But I dont want to use that.
I have the same code, on the other server which works absolutely fine without any issues.
In the same code, no content type is set for response as the file is called direcly using "config.getServletContext().getRequestDispatcher("FILE PATH")".
web.xml are identical on both the server.
Can anyone please suggest what is the other thing that decides the content type for the file to be opened in a browser?
Thanks & Regards
Ketan

To open an Microsoft Word document, you would set the response object's content type to "application/msword" instead of "application/pdf":
// MIME type for MSWord doc
res.setContentType( "application/msword" );
For an Excel document, use the MIME type "application/vnd.ms-excel". In that MIME type, vnd refers to application vendor that must be included to open the file.
In some cases, the browser doesn't recognize the file's MIME type. That often happens when the required plug-in hasn't been installed for a certain file type. In those cases, the browser will pop up a dialog box, asking the user whether he or she wants to open the file or save it to disk.
Content disposition
An HTTP response header named content-disposition allows the servlet to specify information about the file's presentation. Using that header, you can indicate that the content should be opened separately (not actually in the browser) and that it should not be displayed automatically but rather upon some further action by the user. You can also suggest the filename to be used if the content is to be saved to a file. That filename would be the name of the file that appears in the Save As dialog box. If you don't specify the filename, you are likely to get the name of your servlet in that box. To find out more about the content-disposition header, check out Resources.
In the servlet, you want to set that header as follows:
res.setHeader("Content-disposition",
"attachment; filename=" +
"Example.pdf" );
// attachment - since we don't want to open
// it in the browser, but
// with Adobe Acrobat, and set the
// default file name to use.
If you were opening an Microsoft Word file, you would choose:
res.setHeader("Content-disposition",
"attachment; filename" +
"Example.doc" );

Similar Messages

  • Open word document in web browser

    i need to open the word document using activex web browser. just like windows 7 shows the preview panel.
    any body know this?
    Regards,
    Balaji DP

    Hi Rick,
    Did this issue occur with all the files?
    If yes, I recommend to verify the things below:
    Check if the Office Web Apps feature is activated on the site collection.
    Check if the Office Web Apps service applications and proxies have been created.
    Check if the Office Web Apps service applications and proxies are associated with the proxy group of the Web application that the site collection belongs to.
    Check if the service account permissions for the Web application and the Office Web Apps services are appropriate.
    More references:
    http://technet.microsoft.com/en-us/library/hh269604(v=office.14).aspx#bkmk_CannotViewInBrow
    http://social.technet.microsoft.com/wiki/contents/articles/21739.sharepoint-2010-word-web-app-cannot-open-this-document-for-viewing-because-of-an-unexpected-error.aspx
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • How to restrict Firefox to open word document in browser window with href

    How to restrict firefox to open word document from a website link to open in the browser window, instead it should open in native program.
    1.I have tried other website, and have clicked on similar links they are opening word document correctly in native program
    2. MS word document from one specific site is opening in browser causing junk character in place of word document.
    Could you please help on this.

    Thanks for your response...
    But As i said, I have tried with other website on the same browser, there it is opening word document in native program. Also the above mentioned options have been tried earlier.
    I have some questions related to this?
    How is this href link is behaving differently opening in browser for mozilla only. Technically, Can we make it open it native program only? If so, then how?

  • HOW TO OPEN WORD DOCUMENT FROM JAVA???

    hi everyone! Can you please help me to come with this problem? Let me to set my main target I want to achieve:
    1) In my program user should first press a button;
    2) Then already created Word Document should be opened (I DO NOT NEED to open that Word Document in Java or something like JField). Just simply it should be opened as a Microsoft Word Document.
    I DO NEED YOUR HELP! PLEASE HELP ME....!

    Running cmd using the exec is also a windows only solution, there is no "more" or "less" it that solution compared to the rundll.
    Since word is a windows format its pretty obvious that the application is ran under windows platform.
    If you are running on a different platform (maybe using open office you can open word documents, i'm not sure) you might want to use the JDIC library (https://jdic.dev.java.net/) which enables you to open/edit/browse such files using the default viewer/editor/browser of the system you are working on.
    Look at the org.jdesktop.jdic.desktop.Desktop object for these methods.
    You can also find the Desktop object in J2SE6 but its still in beta.

  • How to open word document in labview

    Hi,
    I want to open word document in labview,well i have done that.
    I want to display only the page part,don't want any editions,formatting to be done.
    please suggest me solution if any.

    How are you displaying your Word document, have you achieved that already?
    As far as I know, there is only one way to display Word documents and that's through the browser ActiveX interface:
    Using the Microsoft Web Browser control to embed a Word Document in LabVIEW
    Thoric (CLA, CLED, CTD and LabVIEW Champion)

  • Open word document in jsp

    I have a jsp file and i open a new page(word document) with a link in this jsp page. Text messages are viewed correctly in WS-Word but there is a problem for images...
    1 _ How can i solve this problem?
    2 _ After opening word document, if opened word document is saved to anywhere of computer, how can i know address location of it in jsp?
    First File (a part of code):
    <a style="cursor: hand;"
    onClick="window.open('.../word.jsp','','height=400,width=600,scrollbars=yes,resizable=yes')">
    test link14 - open word file
    </a>
    Second File : (word.jsp) All of the code...
    <%@ page contentType="text/html;charset=windows-1254"%>
    <%
         response.setContentType("application/msword");
         response.setHeader("Content-disposition","attachment;filename=firat_WordDoc.doc");
    %>
    <%@ page language = "java" %>
    <html>
         <head></head>
         <body>
              <img src="car.jpg" width="100" height="100" border="0" alt="car"/>
              <br>
              test text...
         </body>
    </html>
    In second jsp file (word.jsp), "test text..." are written coorectly to word document named firat_WordDoc.doc but car.jpg is not viewed

    You wont be able to see it as becoz all you are doing is asking teh browser to paint a JSP [HTML] Page and asking it to open in the format msword.
    Save the word document and open it in textpad or notepad, you will see that the HTML is embedded within the Word Document rather than binary data. And you can see that the Image will aso be a IMG tag with refeence to the car.jpg.
    In order for you to do this either consider
    1. Using full URL in the Image tag.
    2. Using COM Bridge [JIntegra] License Software to build a new Word Document at runtime and then paint it.
    3. I think POI is free ware to do this.

  • I cannot simply open Word documents. I am forced to save them in order to view them.

    In firefox, IE, and chrome, I try to open Word documents and am forced to save them in order to view them. I do not get the box that asks whether I want to save or open (and yes, I have the option to always ask checked in my settings). When I find the document in my folders, it tells me I'm in protected view when viewing my documents. This has only started recently. The only thing new I've done to the computer recently is update firefox. However, this problem is occurring in all my browsers.
    (I do not have this problem opening other files, like PDF. I still get the option to open or save with files other than Word documents.)
    I have run my Sophos antivirus and have found nothing. I have suspected rookit, but hope it is less serious.
    I also do not wish to download any new programs in order to fix this problem.
    Thank you!

    Try upgrading to the most recent version of Firefox.
    '''Try Firefox Safe Mode''' to see if the problem goes away. Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * On Windows you can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * On Mac you can open Firefox 4.0+ in Safe Mode by holding the '''option''' key while starting Firefox.
    * On Linux you can open Firefox 4.0+ in Safe Mode by quitting Firefox and then going to your Terminal and running: firefox -safe-mode (you may need to specify the Firefox installation path e.g. /usr/lib/firefox)
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    [[Image:FirefoxSafeMode|width=520]]
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    Please report back soon.
    So you don't receive any popup window asking you to save or view the document? The download just begins all by itself.
    <b>NOTE: </b>Even if you select to only view the document, since Firefox has no built in Word viewer, you'll end up downloading it anyway. The only difference is that it will be downloaded into the temporary memory of your computer.

  • HT1338 My mac is becoming too slow. It takes long to open word documents, pdf files or excel documents or even safari. Can anybody suggest something? I have tried to reduce the number of open applications, but does not seem to work.

    My mac is becoming too slow. It takes long to open word documents, pdf files or excel documents or even safari. Can anybody suggest something? I have tried to reduce the number of open applications, but does not seem to work.

    Hi ...
    Checked to see how much free space there is on the startup disk lately?
    Right or control click the MacintoshHD icon. Click Get Info. In the Get Info window you will see Capacity and Available. Make sure there's a minimum of 15% free disk space.
    Freeing Up Hard Disk Space - Mac GuidesFreeing Up Hard Disk Space - Mac Guides
    If disk space is not the issue, booting in Safe Mode deletes system caches that may help.
    A Safe Mode boot takes longer then a normal boot so be patient.
    Once you see the Desktop, click the Apple menu icon top left corner of the screen.
    From the drop down menu click Restart.
    See if that makes a difference ...

  • Got errors when trying to open word document with Office Web App Server and customized WOPI host

    I am configuring the Office Web App Server with our ASP.NET MVC WOPI host based on this example. https://code.msdn.microsoft.com/office/Building-an-Office-Web-f98650d6. While both the OWA server and WOPI server has been set up and I can use Excel and PowerPoint
    app to open and edit xls and ppt file now, there are problems opening word documents no matter I enable or disable the editing function of OWA server.
    When I open a word document while enabling editing I got this error:
    If I disable editing I got this message:
    I have tried several file so I thought it is not the files' problem. Also I didn't find any exception in the log of OWA server. 

    Hi Gary Jiang,
    Thanks for posting in MSDN forum.
    This forum is for developers discussing issues about
    apps for Office.
    Based on the description, it seems that you got an issue when you deploy the code sample. If I understood clearly, I suggest that you contact the author of the code sample from the "Q and A" tab.
    Also if you have the question about WOPI, I suggest that you get more effective response from
    Office
    Protocols forum.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Opening Word documents with Appleworks

    I often receive Word documents as email attachments (though my hotmail account). I can download these Word documents to my desktop but when I click on them to open them I get an offer to purchase MS Word (which I do not have). I would like to be able to simply open the Word documents with Apple works--and I am hoping I can just click on them and have that happen automatically. But it doesn't. I have tried opening Appleworks and going into the wordprocessing program and then opening the Word document through that, but it only is successful part of the time. What can I do? I would like to have these Word douments open automatically in Appleworks but every time I click on them (i.e., their icon on my desktop) I get that advertisement from Microsoft asking me to buy Word. Is this ad blocking a normal function of Appleworks that would otherwise allow me to open Word documents with a click? And in any case, how can I proceed?

    The ad for Word is almost certainly being tacked on through or at Hotmail (taglines or adware from Hotmail? Hoodathunk .....) ; it sure isn't coming from AppleWorks or from anything on your own system, unless you have that demo copy of Office still lurking somewhere. I suppose it could come from that, somehow.
    Assuming you can get a clean attachment downloaded to your Desktop from Hotmail, the procedure for having what you want to happen automatically is fairly straightforward and, really, has nothing at all to do with Appleworks. Try the following:
    --> Select (highlight) one of those downloaded .doc files from Word, then
    --> use the Finder's Get Info command (⌘-I). In the window which appears,
    --> see the "Open with" section, and set it to AppleWorks.

  • Cannot open Word document files in a Portfolio

    I have set up a portfolio with multiple file types. I can open Excel and Power Point files within the portfolio without a problem. When I try to open Word documents it tells me that "Acrobat cannot open this file attachment because your pdf file attachment settings do not allow for this file type to be opened. I went into preferances and checked to see if the box was checked in "trust manager" to allow files other than pdf to opened. It is checked but I am still unable to open word documents in the portfolio for some reason.

    Acrobat cannot open Word files. Have you tried opening the files from within Word? If so, most probably you have a file association problem.

  • Opening word documents

    I was told when I purchased iWork last week that I would be able to open word documents that were sent to me via email. How can I do that?

    maralyala,
    Note that Dennis' solution will result in ALL Word files opening in Pages, as he says.
    If you only want to open the occasional Word files in Pages, right-click or command-click on the file and choose "Open With" from the contextual menu that pops up next to the document. Select Pages.app from the list. If Pages.app is not on the list, click on 'Other' and scroll to Pages.app in your Applications folder.
    You can do this on the icon of the Word file that appears in your email or after saving the Word file to your Mac.
    Good luck,
    Terry

  • Ipad won't open Word documents without .doc appended

    My ipad won't open word documents attached to emails that don't have .doc appended, however my iphone does this flawlessly. Is this normal?

    Mine won't either. I was wondering if it had something to do with installing the pages app. My attachments with .doc are showing as pages docs.

  • How to open word document directly using ole2 and ole containers

    Hello
    i am using ole conatiners....in forms 6i. i want o open word document directly when i click a button....
    i have tried host....ole but word opens .....i want the document to open at once.....
    what should i use /set
    plz tell by host command and ole2 as well
    its urgent.....
    thanks

    Try this code, Hope this will work.
    declare
    item_name varchar2(80) := 'letter';
    item_id item;
    verb_index_str VARCHAR(20);
    verb_index PLS_INTEGER;
    verb_cnt_str VARCHAR(20);
    verb_cnt NUMBER;
    verb_name VARCHAR(20);
    loop_cntr NUMBER;
    begin
    item_id := Find_Item(item_name);
    IF Id_Null(item_id)THEN
              message('No such item: '||item_name);
    ELSE
    verb_cnt_str := Forms_OLE.Get_Verb_Count(item_id);
    verb_cnt := TO_NUMBER(verb_cnt_str);
    FOR loop_cntr in 1..verb_cnt LOOP
    verb_name := Forms_OLE.Get_Verb_Name(item_id,loop_cntr);
    -- message(verb_name);
    -- message(loop_cntr|| ' '||verb_name);
    IF verb_name = 'Open' or Verb_name = '?E?'THEN
    EXEC_VERB(item_id,verb_name);
    END IF;
         end loop;
    end if;
    EXCEPTION
    WHEN OTHERS THEN
    MESSAGE('Error: '||TO_CHAR(SQLCODE)||' '||SQLERRM);
    RAISE FORM_TRIGGER_FAILURE;
    end;

  • How to open word document form html container url iam getting internal_error while opening file

    Hi all,
    By using below code i am able to download word document file from html container. But before downloading i need edit these document to add Macro.
    I am unable to open word document.
    CREATE OBJECT G_HTML_CONTAINER
          EXPORTING
            CONTAINER_NAME = 'PDF'.
       CREATE OBJECT G_HTML_CONTROL
          EXPORTING
            PARENT = G_HTML_CONTAINER.
    * Convert xstring to binary table to pass to the LOAD_DATA method
        CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
          EXPORTING
            BUFFER     = LV_CONTENT
          TABLES
            BINARY_TAB = LT_DATA.
    data_tab = LT_DATA ).
    * Load the HTML
        CALL METHOD G_HTML_CONTROL->LOAD_DATA(
           EXPORTING
             TYPE         = 'application'
             SUBTYPE      = 'DOC'
           IMPORTING
             ASSIGNED_URL         = LV_URL
           CHANGING
             DATA_TABLE           = LT_DATA
           EXCEPTIONS
             DP_INVALID_PARAMETER = 1
             DP_ERROR_GENERAL     = 2
             CNTL_ERROR           = 3
             OTHERS               = 4 ).
    * Show it
        CALL METHOD G_HTML_CONTROL->SHOW_URL( URL = LV_URL
          IN_PLACE = 'X' ).
    Before file download i want edit the file for that i am using below class.
    PROXY TYPE REF TO I_OI_DOCUMENT_PROXY.
    by using (get_document_proxy) method  getting proxy .
    call method control->get_document_proxy
    exporting
    document_format   = 'x'
    document_type      = 'Word.Document'
    register_container  = 'x'
    importing
    document_proxy     = proxy
    after these.
    call method proxy->open_document
    exporting
    document_url    = lv_url
    open_inplace    = 'x'
    hear i m getting retcode as INTERNAL ERROR
    can any one suggest me how to open document from html container.
    Thanks and reagards
    jogu yadav

    I got resolution
    Thanks and regards,
    Jogu yadav

Maybe you are looking for

  • Animated gif issue in IE - files posted

    Hi Linda (and others who would like to check this out), I have posted the files I got from work. They are at: http://www.fayec.com/pngtest/animated3.png http://www.fayec.com/pngtest/animated3.gif You will see that the gif image plays perfectly in Moz

  • Hp dj 2510 how to print on a A9 envelope

    Hi,  I have a HP DJ 2510 as a utility printer - on the advanced setting there is no A9 envelope listing, but lots of weird japanese speciality settings. First, do I have the correct software? If so, how do I get it to print on a fairly common sized A

  • IPad mini retina heating problem

    My iPad gets really hot, if I play games and adjust brightness to full. Does anyone else have this problem?

  • Unable to find receipt

    Hello Team, I had made a purchase within the last 5 days. The item I purchased has not been opened. Is there a way you could help find the receipt?

  • Cannot synchronise with E61i - tried all the tricks posted on web

    I just got my second Nokia E61i but when I try to synchronise it with my contacts and iCal via Bluetooth I get an error message 'Device is not available or synchronization was cancelled. Close dialogs and applications on the phone and try again". The