In my experience this kind of issue usually depends on the content
length value.
As far I can recall, you should be able to monitor net activity
through firebug. Check that content length is equal to the effective
file size.


2010/12/8 CRANFORD, CHRIS <chris.cranf...@setech.com>:
>
> I have several actions in my application where a user can click an
> export option on the page and the content that was rendered to the
> screen gets formatted in a file, zipped, and then streamed to the client
> browser using the stream result type.  The problem is that for one
> particular page, the result seems to be corrupted and the zip file
> cannot be opened, but the same code seems to work in other actions.
>
> public class BaseAction extends ActionSupport
> {
>  private InputStream downloadStream;
>  private String      downloadFileName;
>  private String      downloadContentType;
>  private long        downloadBufferSize;
>  private long        downloadFileSize;
>
>  // getter/setters
> }
>
> public class SupplierAction extends BaseAction
> {
>  public String search()
>  throws Exception
>  {
>    if(doExport())
>    {
>      ByteArrayOutputStream data =
> supplierService.getExportStream(searchCriteria);
>      setDownloadStream(new ByteArrayInputStream(data));
>      setDownloadContentType("application/zip");
>      setDownloadBufferSize(1024);
>      setDownloadFileSize(data.size());
>      setDownloadFileName("suppliers.zip");
>      return "download";
>    }
>
>    vendorList = supplierService.getSearch(searchCriteria);
>    // return to render jsp
>    return SUCCESS;
>  }
> }
>
> In our struts.xml file, I simply defined "download" as a global result
> definition so that all of our applications could easily handle passing
> downloadable content back to the browser if coded.  Here's the
> definition
>
> <global-results>
>  <result name="download" type="stream">
>    <param name="inputName">downloadStream</param>
>    <param name="contentType">${downloadContentType}</param>
>    <param name="bufferSize">${downloadBufferSize}</param>
>    <param name="contentLength">${downloadFileSize}</param>
>    <param name="contentDisposition">attachment;
> filename="${downloadFileName}"</param>
>  </result>
> </global-result>
>
> My initial thought was that the ZIP file was being damaged.  I checked
> in the service layer by having my byte array written to a file on disk,
> the file contents were fine and could be opened locally.  Secondly I
> performed the same test in the action in the event there was a problem
> handing the data back to the action layer.  The contents written to disk
> from the action layer were also fine.
>
> Anyone have any ideas what could be my problem????
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>



-- 
Maurizio Cucchiara

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to