Solved

Java Servlet to stream in Word document into browser

Posted on 2006-07-19
10
1,292 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
10 Comments
 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 25 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 25 total points
ID: 17144244
0
 

Assisted Solution

by:firas981
firas981 earned 25 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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:mayankeagle
mayankeagle earned 25 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now