simples assim no servlet
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
ServletOutputStream stream = response.getOutputStream();
InputStream arquivoReader = new FileInputStream(new File(templatePath));
String fileName = "anexo.rtf";
response.setContentType("application/rtf");
response.setHeader("Content-disposition", "note;filename=\""
+ fileName + "\"");
response.addHeader("Content-description", fileName);
byte[] buf = new byte[1024];
int count = 0;
while ((count = arquivoReader.read(buf)) >= 0) {
stream.write(buf, 0, count); // aqui ocorre o erro
System.out.println(count);
}
arquivoReader.close();
stream.flush();
stream.close();
} catch (Throwable e) {
throw Util.getBaseException(e);
} finally {
try{
os.close();
}catch(IOException io){
throw Util.getBaseException(io);
}
}
Acima do System.out.println(count); ocorre o erro apos ter escrito algumas dezenas de vezes.
erro abaixo
Caused by: ClientAbortException: java.net.SocketException: Software caused connection abort: socket write error
Alguem pode ajudar ?
Uso struts 1.2. fiz varios testes, com a action do struts, fiz um action extendido do downloadAction para gerar o download, e por fim fiz um servlet so pra isto.
em todos da o mesmo erro no mesmo local. Na hora de escrever.
Alguem pode me ajudar ?