• Post Reply Bookmark Topic Watch Topic
  • New Topic

export to doc file  RSS feed

 
suresh pulapally
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

iam trying to download doc files, the follwing code i have written its downloading doc file but it contains ascii values not text.please suggest me.

<%@ page contentType="text/html; charset=utf-8" %>
<%@ page language="java" import="java.io.*"%>

<%
String filePath="";
filePath="D:/baselinejspcode/date7thjune/backup/merlin/downloads/Merlin Site Minder Integration Drfat 0.2.doc";

int bit=256;
int i=0;
response.setContentType("application/msword");
System.out.println(filePath);
response.setHeader ("Content-Disposition", "attachment; filename=merlin.doc");
try{
File uFile= new File(filePath);
String name = uFile.getName().substring(uFile.getName().lastIndexOf("/") + 1,uFile.getName().length());
InputStream fis = new FileInputStream(uFile);
ServletOutputStream outs = response.getOutputStream();
while ((bit) >= 0) {
bit = fis.read();
outs.write(bit);
i++;
}
System.out.println(i);
outs.flush();
outs.close();
fis.close();


fis.close();
pw.flush();
pw=null; */
}catch(Exception e){
}

%>
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe it's:
contentType = "application/vnd.ms-excel"

Streaming binary data really needs to be done from a servlet.
You should be running into IllegalStateExceptions when you try to write to the servletOutputStream from a JSP.
[ June 20, 2005: Message edited by: Ben Souther ]
 
suresh pulapally
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you,

i will try ..
 
suresh pulapally
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you,

i will try ..
 
suresh pulapally
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you,

i got the solution
 
suresh pulapally
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you,

i got the solution
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!