deadMan
deadMan

Reputation: 35

How to open a document in browser

I am trying to open a word document in browser. So, when user wants to view it, I should be able to open the document in browser itself. Is there a way to achieve this??

Present code:

response.addHeader("Content-Type", "application/msword; charset=utf-8")
response.addHeader("Content-disposition", "inline; filename="+"\"testdoucment.doc\"")
response.setContentLength(content.getBytes().length)
response.outputStream<<content.bytes
response.outputStream.flush()
response.flushBuffer()

Upvotes: 0

Views: 223

Answers (1)

woz
woz

Reputation: 11004

The code you have should cause the document to be downloaded. You can't open a Word document in a browser anymore. You used to be able to do that in IE 5 or 6, I think, but that's it.

Here is a question about how to achieve what you're talking about, but neither of the answers have been upvoted or accepted. I'm sure it has to be set up by the user, though. You can't force it to open that way just by using altering the response.

Upvotes: 2

Related Questions