You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andy <an...@hotmail.com> on 2009/05/05 03:48:29 UTC

stream result causing action to be called multiple times

Hi, I have an action that returns a stream result type and for some reason my action is getting called multiple times:

<result name="attachment" type="stream">
   <param name="contentType">${attachmentContentType}</param>
   <param name="contentDisposition">filename="${attachmentFileName}"</param>
</result>

This causes some inefficiency since the action is retrieving an image from the database on each call.  IDeas?

I am on 2.16 and using default interceptor stack.  

Thanks

_________________________________________________________________
Hotmail® goes with you. 
http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009

Re: stream result causing action to be called multiple times

Posted by Chris Pratt <th...@gmail.com>.
Yup, those are wrong, it should be:

<param name="contentDisposition">attachment;
filename="${attachmentFileName}"</param>

Someone with Wiki privileges should probably update those pages.
(*Chris*)

On Tue, May 5, 2009 at 12:44 PM, Andy <an...@hotmail.com> wrote:

>
> I may be reading this doc wrong, but doesnt it state it here?:
>
>
>
>
> http://struts.apache.org/2.1.2/struts2-core/apidocs/org/apache/struts2/dispatcher/StreamResult.html
>
>
>
> Also saw these:
>
> http://stackoverflow.com/questions/257566/using-stream-result-with-struts2
>
> http://sheetalshundori.blogspot.com/2008/02/struts2-dynamic-file-download.html
>
>
>
> > Date: Tue, 5 May 2009 15:23:23 -0400
> > From: dale@newfield.org
> > To: user@struts.apache.org
> > Subject: Re: stream result causing action to be called multiple times
> >
> > Andy wrote:
> > > I have an action that returns a stream result type
> >
> > > <param
> name="contentDisposition">filename="${attachmentFileName}"</param>
> >
> > This mistake is so common I'm wondering if there's some struts tutorial
> > somewhere that gets it wrong. Did you copy that setting from somewhere?
> >
> > http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1
> >
> > -Dale
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
> _________________________________________________________________
> Hotmail® goes with you.
>
> http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009
>

RE: stream result causing action to be called multiple times

Posted by Andy <an...@hotmail.com>.
Yep that totally fixed it.  Thanks!!

Andy

> Date: Tue, 5 May 2009 16:28:53 -0400
> From: dale@newfield.org
> To: user@struts.apache.org
> Subject: Re: stream result causing action to be called multiple times
> 
> Andy wrote:
> > I may be reading this doc wrong, but doesnt it state it here?:
> > 
> > http://struts.apache.org/2.1.2/struts2-core/apidocs/org/apache/struts2/dispatcher/StreamResult.html
> 
> It does.  Thanks for the pointer.  I just created a JIRA issue (WW-3117) 
> to fix that javadoc.
> 
> > Also saw these:
> > 
> > http://stackoverflow.com/questions/257566/using-stream-result-with-struts2
> > http://sheetalshundori.blogspot.com/2008/02/struts2-dynamic-file-download.html
> 
> Which both now have commments correcting the mistake.  Thanks for 
> letting us know where (and thanks to Chris for posting the correcting 
> comments :-)
> 
> -Dale
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Hotmail® has a new way to see what's up with your friends.
http://windowslive.com/Tutorial/Hotmail/WhatsNew?ocid=TXT_TAGLM_WL_HM_Tutorial_WhatsNew1_052009

Re: stream result causing action to be called multiple times

Posted by Wes Wannemacher <we...@wantii.com>.
I take that back, I'm having trouble getting into svn, I guess I just
hadn't noticed that the commit failed.

Anyhow, I'll have it updated as soon as svn comes back to life.

-Wes

On Tue, May 5, 2009 at 4:41 PM, Wes Wannemacher <we...@wantii.com> wrote:
> Dale, I updated the source before you had put the issue in the JIRA.
> I'm going to go ahead and close the JIRA, I just didn't want you to
> think nothing was done since no subversion commits will be tied to it.
>
> -Wes
>
> On Tue, May 5, 2009 at 4:28 PM, Dale Newfield <da...@newfield.org> wrote:
>> Andy wrote:
>>>
>>> I may be reading this doc wrong, but doesnt it state it here?:
>>>
>>>
>>> http://struts.apache.org/2.1.2/struts2-core/apidocs/org/apache/struts2/dispatcher/StreamResult.html
>>
>> It does.  Thanks for the pointer.  I just created a JIRA issue (WW-3117) to
>> fix that javadoc.
>>
>>> Also saw these:
>>>
>>> http://stackoverflow.com/questions/257566/using-stream-result-with-struts2
>>>
>>> http://sheetalshundori.blogspot.com/2008/02/struts2-dynamic-file-download.html
>>
>> Which both now have commments correcting the mistake.  Thanks for letting us
>> know where (and thanks to Chris for posting the correcting comments :-)
>>
>> -Dale
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
>
> --
> Wes Wannemacher
> Author - Struts 2 In Practice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
>



-- 
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

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


Re: stream result causing action to be called multiple times

Posted by Wes Wannemacher <we...@wantii.com>.
Dale, I updated the source before you had put the issue in the JIRA.
I'm going to go ahead and close the JIRA, I just didn't want you to
think nothing was done since no subversion commits will be tied to it.

-Wes

On Tue, May 5, 2009 at 4:28 PM, Dale Newfield <da...@newfield.org> wrote:
> Andy wrote:
>>
>> I may be reading this doc wrong, but doesnt it state it here?:
>>
>>
>> http://struts.apache.org/2.1.2/struts2-core/apidocs/org/apache/struts2/dispatcher/StreamResult.html
>
> It does.  Thanks for the pointer.  I just created a JIRA issue (WW-3117) to
> fix that javadoc.
>
>> Also saw these:
>>
>> http://stackoverflow.com/questions/257566/using-stream-result-with-struts2
>>
>> http://sheetalshundori.blogspot.com/2008/02/struts2-dynamic-file-download.html
>
> Which both now have commments correcting the mistake.  Thanks for letting us
> know where (and thanks to Chris for posting the correcting comments :-)
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

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


Re: stream result causing action to be called multiple times

Posted by Dale Newfield <da...@newfield.org>.
Andy wrote:
> I may be reading this doc wrong, but doesnt it state it here?:
> 
> http://struts.apache.org/2.1.2/struts2-core/apidocs/org/apache/struts2/dispatcher/StreamResult.html

It does.  Thanks for the pointer.  I just created a JIRA issue (WW-3117) 
to fix that javadoc.

> Also saw these:
> 
> http://stackoverflow.com/questions/257566/using-stream-result-with-struts2
> http://sheetalshundori.blogspot.com/2008/02/struts2-dynamic-file-download.html

Which both now have commments correcting the mistake.  Thanks for 
letting us know where (and thanks to Chris for posting the correcting 
comments :-)

-Dale

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


RE: stream result causing action to be called multiple times

Posted by Andy <an...@hotmail.com>.
I may be reading this doc wrong, but doesnt it state it here?:

 

http://struts.apache.org/2.1.2/struts2-core/apidocs/org/apache/struts2/dispatcher/StreamResult.html

 

Also saw these:

http://stackoverflow.com/questions/257566/using-stream-result-with-struts2
http://sheetalshundori.blogspot.com/2008/02/struts2-dynamic-file-download.html


 
> Date: Tue, 5 May 2009 15:23:23 -0400
> From: dale@newfield.org
> To: user@struts.apache.org
> Subject: Re: stream result causing action to be called multiple times
> 
> Andy wrote:
> > I have an action that returns a stream result type
> 
> > <param name="contentDisposition">filename="${attachmentFileName}"</param>
> 
> This mistake is so common I'm wondering if there's some struts tutorial 
> somewhere that gets it wrong. Did you copy that setting from somewhere?
> 
> http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1
> 
> -Dale
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Hotmail® goes with you. 
http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009

Re: stream result causing action to be called multiple times

Posted by Dale Newfield <da...@newfield.org>.
Andy wrote:
> I have an action that returns a stream result type

>    <param name="contentDisposition">filename="${attachmentFileName}"</param>

This mistake is so common I'm wondering if there's some struts tutorial 
somewhere that gets it wrong.  Did you copy that setting from somewhere?

http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1

-Dale

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


RE: stream result causing action to be called multiple times

Posted by Martin Gainty <mg...@hotmail.com>.

To forestall double submits, and "back button" resubmits,
    the framework can generate a token that is embedded in the form
    and also kept in the session.
    If the value of the tokens do not compare,
    then we know that there has been a problem,
    and that a form has been submitted twice or out of sequence.


may want to look at implementing default-interceptor-ref as a double-submit guard e.g. user-submit
struts.xml:
<interceptors>
  <interceptor name="authentication"=
               class="mailreader2.AuthenticationInterceptor"/>
  <interceptor name="token-session"
               class="com.opensymphony.webwork.interceptor.TokenSessionStoreInterceptor"/>
  <interceptor-stack name="user" >
      <interceptor-ref name="authentication" />
      <interceptor-ref name="defaultStack"/>
  </interceptor-stack>
  <interceptor-stack name="user-submit" >
      <interceptor-ref name="tokenSession" />
      <interceptor-ref name="user"/>
  </interceptor-stack>

<default-interceptor-ref name="user-submit"/>
</interceptors>
<action name="Subscription_save" method="save" class="mailreader2.Subscription">
  <interceptor-ref name="user-submit" />
</action>
you can d/l what you need from here 
http://svn.apache.org/repos/asf/struts/struts2/trunk/apps/mailreader/src/main/webapp/tour.html
or you can d/l the entire struts2 distro and seek for tour.html (under mailreader)

HTH
Martin
______________________________________________ 
Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
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.




> From: andrhahn@hotmail.com
> To: user@struts.apache.org
> Subject: RE: stream result causing action to be called multiple times
> Date: Tue, 5 May 2009 08:40:43 -0500
> 
> 
> >> is multiple equal 2?
> 
>  
> 
> It calls the action between 2 and 4 times, but usually 3.  I was thinking an interceptor would somehow call the action multiple times but maybe that's not possible.  I don't fully understand how interceptors call actions. etc yet :)
> 
>  
> 
> I was testing on a Mac.  OSX/Firefox.  I will try testing on windows/IE.  
> 
>  
> 
> Thanks
> 
> 
>  
> > Date: Tue, 5 May 2009 04:08:49 -0200
> > Subject: Re: stream result causing action to be called multiple times
> > From: poulwiel@gmail.com
> > To: user@struts.apache.org
> > 
> > Hi Andy,
> 
> > If so maybe the browser is doing it because it doesn't know everything
> > about this file - size comes to mind.
> > If i remember correctly some browsers will do that.
> > 
> > best greetings,
> > Pawel Wielgus.
> > 
> > 2009/5/4, Andy <an...@hotmail.com>:
> > >
> > > Hi, I have an action that returns a stream result type and for some reason
> > > my action is getting called multiple times:
> > >
> > > <result name="attachment" type="stream">
> > > <param name="contentType">${attachmentContentType}</param>
> > > <param name="contentDisposition">filename="${attachmentFileName}"</param>
> > > </result>
> > >
> > > This causes some inefficiency since the action is retrieving an image from
> > > the database on each call. IDeas?
> > >
> > > I am on 2.16 and using default interceptor stack.
> > >
> > > Thanks
> > >
> > > _________________________________________________________________
> > > Hotmail® goes with you.
> > > http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> 
> _________________________________________________________________
> Hotmail® goes with you. 
> http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009

_________________________________________________________________
Windows Live™: Keep your life in sync.
http://windowslive.com/explore?ocid=TXT_TAGLM_BR_life_in_synch_052009

RE: stream result causing action to be called multiple times

Posted by Andy <an...@hotmail.com>.
>> is multiple equal 2?

 

It calls the action between 2 and 4 times, but usually 3.  I was thinking an interceptor would somehow call the action multiple times but maybe that's not possible.  I don't fully understand how interceptors call actions. etc yet :)

 

I was testing on a Mac.  OSX/Firefox.  I will try testing on windows/IE.  

 

Thanks


 
> Date: Tue, 5 May 2009 04:08:49 -0200
> Subject: Re: stream result causing action to be called multiple times
> From: poulwiel@gmail.com
> To: user@struts.apache.org
> 
> Hi Andy,

> If so maybe the browser is doing it because it doesn't know everything
> about this file - size comes to mind.
> If i remember correctly some browsers will do that.
> 
> best greetings,
> Pawel Wielgus.
> 
> 2009/5/4, Andy <an...@hotmail.com>:
> >
> > Hi, I have an action that returns a stream result type and for some reason
> > my action is getting called multiple times:
> >
> > <result name="attachment" type="stream">
> > <param name="contentType">${attachmentContentType}</param>
> > <param name="contentDisposition">filename="${attachmentFileName}"</param>
> > </result>
> >
> > This causes some inefficiency since the action is retrieving an image from
> > the database on each call. IDeas?
> >
> > I am on 2.16 and using default interceptor stack.
> >
> > Thanks
> >
> > _________________________________________________________________
> > Hotmail® goes with you.
> > http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Hotmail® goes with you. 
http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009

Re: stream result causing action to be called multiple times

Posted by Paweł Wielgus <po...@gmail.com>.
Hi Andy,
is multiple equal 2?
If so maybe the browser is doing it because it doesn't know everything
about this file - size comes to mind.
If i remember correctly some browsers will do that.

best greetings,
Pawel Wielgus.

2009/5/4, Andy <an...@hotmail.com>:
>
> Hi, I have an action that returns a stream result type and for some reason
> my action is getting called multiple times:
>
> <result name="attachment" type="stream">
>    <param name="contentType">${attachmentContentType}</param>
>    <param name="contentDisposition">filename="${attachmentFileName}"</param>
> </result>
>
> This causes some inefficiency since the action is retrieving an image from
> the database on each call.  IDeas?
>
> I am on 2.16 and using default interceptor stack.
>
> Thanks
>
> _________________________________________________________________
> Hotmail® goes with you.
> http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009

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