This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

export to doc file

 
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){
}

%>
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • 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
 
See ya later boys, I think I'm in love. Oh wait, she's just a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!