?
Solved

Java Servlet to stream in Word document into browser

Posted on 2006-07-19
10
Medium Priority
?
1,693 Views
Last Modified: 2013-11-24
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
0
Comment
Question by:gvijay1
8 Comments
 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 100 total points
ID: 17143687
You should add "Content-Disposition" header also:

http://support.microsoft.com/kb/260519/EN-US/
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17143704
Like

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

0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 100 total points
ID: 17144244
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Assisted Solution

by:firas981
firas981 earned 100 total points
ID: 17170798
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
 

Expert Comment

by:firas981
ID: 17170823
Of course this is true only if the document is opened using the microsoft word in external window
(not inside the browser).
0
 

Author Comment

by:gvijay1
ID: 17175361
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
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 100 total points
ID: 17175432
Then perhaps IE is not configured to open Word files at all (no plug-in or plug-in disabled)
0
 

Expert Comment

by:firas981
ID: 17184302
JC_ActiveDoc
http://www.jcsoft.com/docobject/

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

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question