Link to home
Start Free TrialLog in
Avatar of gvijay1
gvijay1

asked on

Java Servlet to stream in Word document into browser

Experts,

I am using a Servlet to read a MS Word document from a remote server and display it to the user within the IE browser. My servlet looks like this:

The document is located in: http://server/Document.doc

1. res.setContentType( "application/msword" );
2. Open  URL connection to the above document.
3. Read the contents and write.

When I access the servlet, I am getting an annoying pop-up asking me to Open or Save the contents. WHen I click Open, the correct file is opened (so, it is accessing the document correctly). How can I automatically open the contents in a browser window instead of prompting the user with that Download pop-up?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Ajay-Singh
Ajay-Singh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ajay-Singh
Ajay-Singh

Like

res.addHeader("Content-Disposition", "inline; filename=Document.doc");

SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Of course this is true only if the document is opened using the microsoft word in external window
(not inside the browser).
Avatar of gvijay1

ASKER

I tried using the Content-Disposition field as well as described above, but it does not work either. The download box still opens asking for user input. When I click OK to open, the document is not opened within a browser window but instead in MS Word itself.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
JC_ActiveDoc
http://www.jcsoft.com/docobject/

It is for netscape, but it worked for me with IE 6.0