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

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -