Download a XML file via jsf -


i trying download xmls file zipped archive using richfaces. have done usual way of downloading files. have requirement download zip .xlsx files. same piece of code working zipped archive of xlsx files.

i have throwdownload() follows..

  public void throwdownload(bytearrayoutputstream baos, string filename) throws ioexception {      facescontext facescontext = facescontext.getcurrentinstance();     externalcontext externalcontext = facescontext.getexternalcontext();     httpservletresponse response = (httpservletresponse) externalcontext             .getresponse();       response.reset();     response.setcontenttype("application/zip");     response.setcontentlength( baos.size() );     response.setheader("content-disposition", "attachment; filename=\""             + filename + "\"");      bufferedoutputstream output = null;     final int buffersize = 20480;      output = new bufferedoutputstream(response.getoutputstream(),             buffersize);     output.write(baos.tobytearray());      facescontext.responsecomplete();  } 

the same code works fine zip containing .xlsx files. zip containing .xml files save dialog shown browser downloaded file having 0 bytes. response headers in fiddler 2 requests follows:

xml files zip:-

http/1.1 200 ok server: apache-coyote/1.1 content-disposition: attachment; filename="crs_files.zip" content-type: application/zip content-length: 1426 date: sun, 06 apr 2014 14:42:50 gmt 

xlsx files zip:-

http/1.1 200 ok server: apache-coyote/1.1 content-disposition: attachment; filename="datacheckreports.zip" content-type: application/zip transfer-encoding: chunked date: sun, 06 apr 2014 15:00:37 gmt 


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -