You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "CRANFORD, CHRIS" <Ch...@setech.com> on 2010/12/08 18:04:54 UTC
Result Type Stream Corrupted
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
RE: RE: RE: Result Type Stream Corrupted
Posted by "CRANFORD, CHRIS" <Ch...@setech.com>.
No, both the client saved file and the one created on the server side in the temp directory both match in size.
> -----Original Message-----
> From: Li Ying [mailto:liying.cn.2010@gmail.com]
> Sent: Wednesday, December 08, 2010 6:07 PM
> To: Struts Users Mailing List
> Subject: Re: RE: RE: Result Type Stream Corrupted
>
> Are the file size different?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
Re: RE: RE: Result Type Stream Corrupted
Posted by Li Ying <li...@gmail.com>.
Are the file size different?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Result Type Stream Corrupted
Posted by "CRANFORD, CHRIS" <Ch...@setech.com>.
ByteArrayInputStream.
My service writes to a ByteArrayOutputStream which gets converted to a ByteArrayInputStream so that it can be handed off to the stream result type handler.
> -----Original Message-----
> From: Martin Gainty [mailto:mgainty@hotmail.com]
> Sent: Wednesday, December 08, 2010 7:15 PM
> To: Struts Users Mailing List
> Subject: RE: Result Type Stream Corrupted
>
>
> which stream class is being implemented?
>
> http://www.visionlab.uncc.edu/~arwillis/online/docs/jdk-6-
> docs/api/java/io/package-summary.html ?
>
> Martin
> ______________________________________________
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de
> confidentialité
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede
> unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig.
> Diese Nachricht dient lediglich dem Austausch von Informationen und
> entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten
> Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt
> uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas
> le destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la
> copie de ceci est interdite. Ce message sert à l'information seulement
> et n'aura pas n'importe quel effet légalement obligatoire. Étant donné
> que les email peuvent facilement être sujets à la manipulation, nous ne
> pouvons accepter aucune responsabilité pour le contenu fourni.
>
>
>
>
>
> > Date: Thu, 9 Dec 2010 01:15:15 +0100
> > Subject: Re: RE: RE: RE: Result Type Stream Corrupted
> > From: maurizio.cucchiara@gmail.com
> > To: user@struts.apache.org
> >
> > There wouldn't be any difference between get and post request for
> struts
> > (struts acts as filter and AFAIK at that abstraction level there
> would be no
> > method awareness).
> > I'd take a look at the client and server enviroment (like application
> > server)
> >
> > Maurizio Cucchiara
> >
> > Il giorno 09/dic/2010 00.05, "CRANFORD, CHRIS"
> <Ch...@setech.com>
> > ha scritto:
> > 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 ...
> > ---------------------------------------------------------------------
> >
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-hel...
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Result Type Stream Corrupted
Posted by Martin Gainty <mg...@hotmail.com>.
which stream class is being implemented?
http://www.visionlab.uncc.edu/~arwillis/online/docs/jdk-6-docs/api/java/io/package-summary.html ?
Martin
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> Date: Thu, 9 Dec 2010 01:15:15 +0100
> Subject: Re: RE: RE: RE: Result Type Stream Corrupted
> From: maurizio.cucchiara@gmail.com
> To: user@struts.apache.org
>
> There wouldn't be any difference between get and post request for struts
> (struts acts as filter and AFAIK at that abstraction level there would be no
> method awareness).
> I'd take a look at the client and server enviroment (like application
> server)
>
> Maurizio Cucchiara
>
> Il giorno 09/dic/2010 00.05, "CRANFORD, CHRIS" <Ch...@setech.com>
> ha scritto:
> 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 ...
> ---------------------------------------------------------------------
>
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-hel...
RE: RE: RE: RE: Result Type Stream Corrupted
Posted by "CRANFORD, CHRIS" <Ch...@setech.com>.
Both are the same machine, running Tomcat 7.0.4 on Windows 7.
> -----Original Message-----
> From: Maurizio Cucchiara [mailto:maurizio.cucchiara@gmail.com]
> Sent: Wednesday, December 08, 2010 6:15 PM
> To: Struts Users Mailing List
> Subject: Re: RE: RE: RE: Result Type Stream Corrupted
>
> There wouldn't be any difference between get and post request for
> struts
> (struts acts as filter and AFAIK at that abstraction level there would
> be no
> method awareness).
> I'd take a look at the client and server enviroment (like application
> server)
>
> Maurizio Cucchiara
>
> Il giorno 09/dic/2010 00.05, "CRANFORD, CHRIS"
> <Ch...@setech.com>
> ha scritto:
> 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 ...
> ---------------------------------------------------------------------
>
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-hel...
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: RE: RE: RE: Result Type Stream Corrupted
Posted by Maurizio Cucchiara <ma...@gmail.com>.
There wouldn't be any difference between get and post request for struts
(struts acts as filter and AFAIK at that abstraction level there would be no
method awareness).
I'd take a look at the client and server enviroment (like application
server)
Maurizio Cucchiara
Il giorno 09/dic/2010 00.05, "CRANFORD, CHRIS" <Ch...@setech.com>
ha scritto:
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 ...
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-hel...
RE: RE: RE: Result Type Stream Corrupted
Posted by "CRANFORD, CHRIS" <Ch...@setech.com>.
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"
> <Ch...@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"
> >> <Ch...@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 <Ch...@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
Re: RE: RE: Result Type Stream Corrupted
Posted by Maurizio Cucchiara <ma...@gmail.com>.
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" <Ch...@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"
>> <Ch...@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 <Ch...@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
>
RE: RE: Result Type Stream Corrupted
Posted by "CRANFORD, CHRIS" <Ch...@setech.com>.
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"
> <Ch...@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 <Ch...@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
Re: RE: Result Type Stream Corrupted
Posted by Maurizio Cucchiara <ma...@gmail.com>.
Did you get this behavior with different browser?
Maurizio Cucchiara
Il giorno 08/dic/2010 19.47, "CRANFORD, CHRIS" <Ch...@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 <Ch...@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
>
RE: Result Type Stream Corrupted
Posted by "CRANFORD, CHRIS" <Ch...@setech.com>.
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 <Ch...@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
Re: Result Type Stream Corrupted
Posted by Maurizio Cucchiara <ma...@gmail.com>.
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 <Ch...@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