struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "CRANFORD, CHRIS" <Chris.Cranf...@setech.com>
Subject RE: RE: RE: Result Type Stream Corrupted
Date Wed, 08 Dec 2010 23:05:09 GMT
If I compare the binary data written to disk from the browser to that of
the file written on the server (mind you both locally on the same
machine) the actually contents seem different as if the stream had
certain bytes shifted or altered for some reason.  They just do not look
the same.

> -----Original Message-----
> From: Maurizio Cucchiara [mailto:maurizio.cucchiara@gmail.com]
> Sent: Wednesday, December 08, 2010 4:44 PM
> To: Struts Users Mailing List
> Subject: Re: RE: RE: Result Type Stream Corrupted
> 
> And was the content of file really corrupt or something like smaller
> than
> expexcted result (data truncated)?
> 
> Maurizio Cucchiara
> 
> Il giorno 08/dic/2010 23.05, "CRANFORD, CHRIS"
> <Chris.Cranford@setech.com>
> ha scritto:
> > No, behavior was the same between Firefox and IE.
> > The ZIP file simply could not be opened as Explorer felt it was
> invalid.
> >
> >> -----Original Message-----
> >> From: Maurizio Cucchiara [mailto:maurizio.cucchiara@gmail.com]
> >> Sent: Wednesday, December 08, 2010 2:45 PM
> >> To: Struts Users Mailing List
> >> Subject: Re: RE: Result Type Stream Corrupted
> >>
> >> Did you get this behavior with different browser?
> >>
> >> Maurizio Cucchiara
> >>
> >> Il giorno 08/dic/2010 19.47, "CRANFORD, CHRIS"
> >> <Chris.Cranford@setech.com>
> >> ha scritto:
> >> > Found the culprit, but it doesn't make any sense to me.
> >> >
> >> > This one particular page was triggering the export by using a GET
> >> operation. The other pages where it was working fine was using
> >> javascript to
> >> set a form value and then submitted the form to the action,
> inevitably
> >> doing
> >> a POST operation instead.
> >> >
> >> > Why would GET vs POST make a difference in this case?
> >> >
> >> >> -----Original Message-----
> >> >> From: Maurizio Cucchiara [mailto:maurizio.cucchiara@gmail.com]
> >> >> Sent: Wednesday, December 08, 2010 12:14 PM
> >> >> To: Struts Users Mailing List
> >> >> Subject: Re: Result Type Stream Corrupted
> >> >>
> >> >> 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.Cranford@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-unsubscribe@struts.apache.org
> >> >> > For additional commands, e-mail: user-help@struts.apache.org
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> Maurizio Cucchiara
> >> >>
> >> >>
> > --------------------------------------------------------------------
> >> -
> >> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> >> For additional commands, e-mail: user-help@struts.apache.org
> >> >>
> >> >
> >> >
> >> >
> >> >
> >
---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> > For additional commands, e-mail: user-help@struts.apache.org
> >> >
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >


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


Mime
View raw message