Bookmark Topic Watch Topic
  • New Topic

problem with save-as dialog ;rtf file download

 
madhu gun
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi guys,
i have got a similar problem with downloading rtf
file.
I was reading an rtf file from local system(servlet system) and it was downloading fine in browser with correct name with save as dialog ofcourse my browser has rtf plugin.
But I have changed the code now as getting the file as a string from my ejb and writing the string to the out with setContentType and setContentHeader as it is.but now it directly opens in browser.
But if the file is procured by reading from file system by servlet,then the save as dialog does not have problem.
I tried using servletoutputstream.write(bytearray) also after conevrting the string into bytearray using getBytes.it doesn't work .Any ideas please.
resp.setContentType("application/x-filler");
fiStream.available();
resp.setHeader("Content-Disposition","attachment;filename="+file);
soStream=resp.getOutputStream();
fr=new FileReader("C:\\Program Files\\mantra\\"+file);
br= new BufferedReader(fr);
for(int m=0;;m++){
String readLine=br.readLine();
if(readLine==null)
break;

out.write(readLine);
//out.println(readLine);
}
br.close();
out.close();//snippet xyz close
*/
byte[]byteArray=file.getBytes();
soStream.write(byteArray);//snippet abc
soStream.close();//snippet abc

regards
madhu
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!