working as a Programmer
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sudha_Nair
Posted On:   Sunday, December 15, 2002 11:29 PM



How can I view an MS-Word file in JSP in the word format.

Re: working as a Programmer

Posted By:   Sujatha_Gopal  
Posted On:   Monday, December 16, 2002 08:35 PM

Try by using anchor tag.




(a href=MsWordFile.doc)Word File(/a)


Click on the file which will display the file in the word format.

Re: working as a Programmer

Posted By:   Lasse_Koskela  
Posted On:   Monday, December 16, 2002 02:24 AM

Set the content type of the response to "application/ms-word" or something like that (browse the web for the correct MIME type), and write the raw contents of the .doc file to the response's output stream.


Here's a quick example for the JSP, although this kind of "raw" output is definitely better to implement directly as a servlet (because of more strict/clear control over output).



<%@ page language="java" %>
<%@ page import="..." %>
<%
// set the content type so that the browser knows
// what to do with it...
response.setContentType("application/ms-word");

// get a hold of the Word document...
InputStream doc = getWordDocumentStream("foo.doc");

// write the contents of the .doc into response stream
writeInputStreamToResponse(doc);
%>
About | Sitemap | Contact