Solved

Java Servlet to stream in Word document into browser

Posted on 2006-07-19
10
1,315 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

895 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