Solved

Java Servlet to stream in Word document into browser

Posted on 2006-07-19
10
1,395 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: 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 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
 

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 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adding multiple JVM environments to RedHat 6 7 69
ejb entity bean example 2 36
Html Table Looping (part 2) 5 35
What browser will run Java? 7 126
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
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:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

749 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