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
gvijay1Asked:
Who is Participating?
 
Ajay-SinghConnect With a Mentor Commented:
You should add "Content-Disposition" header also:

http://support.microsoft.com/kb/260519/EN-US/
0
 
Ajay-SinghCommented:
Like

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

0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
firas981Connect With a Mentor Commented:
Your browser must has a plugin that is capable of reading the file! Browsers usually display the download box when they don't know how to open them.
0
 
firas981Commented:
Of course this is true only if the document is opened using the microsoft word in external window
(not inside the browser).
0
 
gvijay1Author Commented:
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.
0
 
Mayank SConnect With a Mentor Associate Director - Product EngineeringCommented:
Then perhaps IE is not configured to open Word files at all (no plug-in or plug-in disabled)
0
 
firas981Commented:
JC_ActiveDoc
http://www.jcsoft.com/docobject/

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

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.