java - jax-rs Download file from server -
i trying download file server rest request. request sent, seems fine get: org.jboss.resteasy.spi.writerexception: java.io.ioexception: stream closed.
i think might because jsf processing response afterwards. use: facescontext.responsecomplete();
rest request not have access facescontext (it null).
here java code:
response.setcontenttype(piecejointe.getcontenttype()); response.addheader("content-disposition", "attachment; filename=\"" + piecejointe.getnom() +"\""); if (file.exists()) { fileinputstream fi; try { fi = new fileinputstream(file); servletoutputstream os = response.getoutputstream(); int b = fi.read(); while (b != -1) { os.write(b); b = fi.read(); } os.flush(); os.close(); fi.close(); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } }
what doing wrong ? :s
thanks !
Comments
Post a Comment