You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Yiorgos Panayiotakis <y....@gmail.com> on 2010/05/05 10:30:21 UTC
ExecAndWait interceptor parameters lost
Hi,
I have an issue in my code that I can't resolve and I would appreciate your
help.
I am using the struts2 execAndWait interceptor when I submit a form on my
site.
Below is the relevant struts.xml snippet
<interceptor-stack name="loadingStack">
<interceptor-ref name="defaultStack" />
<interceptor-ref name="execAndWait" />
</interceptor-stack>
<action name="ProcessTripForm" class="actions.ProcessTripForm">
<interceptor-ref name="loadingStack"></interceptor-ref>
<result name="input">/jsp/unscheduled.jsp</result>
<result name="success" type="chain">ProcessTrips</result>
<result name="wait">/jsp/wait.jsp</result>
</action>
<action name="ProcessTrips"
class="actions.ProcessTrips">
<result name="success">/jsp/results.jsp</result>
<result
name="noFilteredResults">/jsp/emptyFilteredResults.jsp</result>
<result name="none">/jsp/no_results.jsp</result>
</action>
The problem I have, is that when I submit my form via POST and produce
some results then if I try to refresh the results page (results.jsp) those
data previously
send via POST do not exist anymore, so I'm redirected to the wait page and
finally because data do not exist to an error page (that does not happen in
Firefox where data somehow are preserved in refresh). Obviously data are
erased
the first time the wait page is auto-refreshed. FYI here is a simplified
version
of my wait.jsp
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="3;<s:url includeParams="all"/>"/>
<title>Wait Page</title>
</head>
<body>
<div>
<p>Waiting...</p>
</div>
</body>
</html>
I could solve this problem by using includeParams="all" in s:url (as seen
above) when
refreshing wait page but then the data are seen in the URL (aside the fact
that there is
a ton of data).Also, when data are not latin characters then after the first
refresh the
character encoding in URL fails, so cannot be used later for repeating the
request with
refresh (e.g. ProcessTripForm.action?originCity=Ηράκλειο is becoming after
the first
refresh
ProcessTripForm.action?originCity=%26%23xCE%3B%26%23x97%3B%26%23xCF%3B
%26%23x81%3B%26%23xCE%3B%26%23xAC%3B and continues to expand).
My question is how can I preserve data when I use the execAndWait
interceptor and use a
POST request in a way that when I'm on result page and hit refresh the same
request will
be repeated?
If that is not possible, and I have the data on my URL via GET and
includeParams then what
do I have to do so encoding does not fail ?
Re: ExecAndWait interceptor parameters lost
Posted by Robert Graf-Waczenski <rg...@lsoft.com>.
Am 05.05.2010 12:42, schrieb Yiorgos Panayiotakis:
> Thank you,
> Though I have little experience in web development I was aware of that, but
> I avoided using
> sessions due to the fact that a user could open multiple tabs in a browser
> and issue multiple
> requests that would belong to the same session. So if he tried to refresh an
> older request this
> would return him the results of a newer request (because last request
> parameters would be
> saved in session) causing confusion to the user.
>
Maybe that's the first thing you need to learn now. Two different
requests are two different requests, period. Either you use URL
rewriting to pass parameters from one request to the next or you use
session attributes. I personally prefer the latter. I'm not too familiar
with the ExecAndWait interceptor but i would not be surprised if it does
not work with URL rewriting at all, so you may be forced to use session
attributes.
Robert
> On Wed, May 5, 2010 at 12:06 PM, Alex Rodriguez Lopez<
> alopez@flordeutopia.pt> wrote:
>
>
>> Hi,
>>
>> you can store data in session and retrieve it later on. Data stored in
>> session is persisted through requests.
>>
>> ActionContext.getContext().getSession();
>>
>>
>> http://struts.apache.org/2.1.8.1/struts2-core/apidocs/com/opensymphony/xwork2/ActionContext.html
>>
>>
>> Hi,
>>
>>> I have an issue in my code that I can't resolve and I would appreciate
>>> your
>>> help.
>>> I am using the struts2 execAndWait interceptor when I submit a form on my
>>> site.
>>> Below is the relevant struts.xml snippet
>>>
>>> <interceptor-stack name="loadingStack">
>>> <interceptor-ref name="defaultStack" />
>>> <interceptor-ref name="execAndWait" />
>>> </interceptor-stack>
>>>
>>> <action name="ProcessTripForm" class="actions.ProcessTripForm">
>>> <interceptor-ref name="loadingStack"></interceptor-ref>
>>> <result name="input">/jsp/unscheduled.jsp</result>
>>> <result name="success" type="chain">ProcessTrips</result>
>>> <result name="wait">/jsp/wait.jsp</result>
>>> </action>
>>>
>>> <action name="ProcessTrips"
>>> class="actions.ProcessTrips">
>>> <result name="success">/jsp/results.jsp</result>
>>> <result
>>> name="noFilteredResults">/jsp/emptyFilteredResults.jsp</result>
>>> <result name="none">/jsp/no_results.jsp</result>
>>> </action>
>>>
>>> The problem I have, is that when I submit my form via POST and produce
>>> some results then if I try to refresh the results page (results.jsp) those
>>> data previously
>>> send via POST do not exist anymore, so I'm redirected to the wait page and
>>> finally because data do not exist to an error page (that does not happen
>>> in
>>> Firefox where data somehow are preserved in refresh). Obviously data are
>>> erased
>>> the first time the wait page is auto-refreshed. FYI here is a simplified
>>> version
>>> of my wait.jsp
>>>
>>> <html xmlns="http://www.w3.org/1999/xhtml">
>>>
>>> <head>
>>> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
>>> <meta http-equiv="refresh" content="3;<s:url includeParams="all"/>"/>
>>>
>>> <title>Wait Page</title>
>>> </head>
>>>
>>> <body>
>>>
>>> <div>
>>> <p>Waiting...</p>
>>> </div>
>>>
>>> </body>
>>> </html>
>>>
>>> I could solve this problem by using includeParams="all" in s:url (as seen
>>> above) when
>>> refreshing wait page but then the data are seen in the URL (aside the fact
>>> that there is
>>> a ton of data).Also, when data are not latin characters then after the
>>> first
>>> refresh the
>>> character encoding in URL fails, so cannot be used later for repeating the
>>> request with
>>> refresh (e.g. ProcessTripForm.action?originCity=Ηράκλειο is becoming after
>>> the first
>>> refresh
>>> ProcessTripForm.action?originCity=%26%23xCE%3B%26%23x97%3B%26%23xCF%3B
>>> %26%23x81%3B%26%23xCE%3B%26%23xAC%3B and continues to expand).
>>>
>>> My question is how can I preserve data when I use the execAndWait
>>> interceptor and use a
>>> POST request in a way that when I'm on result page and hit refresh the
>>> same
>>> request will
>>> be repeated?
>>> If that is not possible, and I have the data on my URL via GET and
>>> includeParams then what
>>> do I have to do so encoding does not fail ?
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> 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: ExecAndWait interceptor parameters lost
Posted by Yiorgos Panayiotakis <y....@gmail.com>.
Thank you,
Though I have little experience in web development I was aware of that, but
I avoided using
sessions due to the fact that a user could open multiple tabs in a browser
and issue multiple
requests that would belong to the same session. So if he tried to refresh an
older request this
would return him the results of a newer request (because last request
parameters would be
saved in session) causing confusion to the user.
On Wed, May 5, 2010 at 12:06 PM, Alex Rodriguez Lopez <
alopez@flordeutopia.pt> wrote:
> Hi,
>
> you can store data in session and retrieve it later on. Data stored in
> session is persisted through requests.
>
> ActionContext.getContext().getSession();
>
>
> http://struts.apache.org/2.1.8.1/struts2-core/apidocs/com/opensymphony/xwork2/ActionContext.html
>
>
> Hi,
>>
>> I have an issue in my code that I can't resolve and I would appreciate
>> your
>> help.
>> I am using the struts2 execAndWait interceptor when I submit a form on my
>> site.
>> Below is the relevant struts.xml snippet
>>
>> <interceptor-stack name="loadingStack">
>> <interceptor-ref name="defaultStack" />
>> <interceptor-ref name="execAndWait" />
>> </interceptor-stack>
>>
>> <action name="ProcessTripForm" class="actions.ProcessTripForm">
>> <interceptor-ref name="loadingStack"></interceptor-ref>
>> <result name="input">/jsp/unscheduled.jsp</result>
>> <result name="success" type="chain">ProcessTrips</result>
>> <result name="wait">/jsp/wait.jsp</result>
>> </action>
>>
>> <action name="ProcessTrips"
>> class="actions.ProcessTrips">
>> <result name="success">/jsp/results.jsp</result>
>> <result
>> name="noFilteredResults">/jsp/emptyFilteredResults.jsp</result>
>> <result name="none">/jsp/no_results.jsp</result>
>> </action>
>>
>> The problem I have, is that when I submit my form via POST and produce
>> some results then if I try to refresh the results page (results.jsp) those
>> data previously
>> send via POST do not exist anymore, so I'm redirected to the wait page and
>> finally because data do not exist to an error page (that does not happen
>> in
>> Firefox where data somehow are preserved in refresh). Obviously data are
>> erased
>> the first time the wait page is auto-refreshed. FYI here is a simplified
>> version
>> of my wait.jsp
>>
>> <html xmlns="http://www.w3.org/1999/xhtml">
>>
>> <head>
>> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
>> <meta http-equiv="refresh" content="3;<s:url includeParams="all"/>"/>
>>
>> <title>Wait Page</title>
>> </head>
>>
>> <body>
>>
>> <div>
>> <p>Waiting...</p>
>> </div>
>>
>> </body>
>> </html>
>>
>> I could solve this problem by using includeParams="all" in s:url (as seen
>> above) when
>> refreshing wait page but then the data are seen in the URL (aside the fact
>> that there is
>> a ton of data).Also, when data are not latin characters then after the
>> first
>> refresh the
>> character encoding in URL fails, so cannot be used later for repeating the
>> request with
>> refresh (e.g. ProcessTripForm.action?originCity=Ηράκλειο is becoming after
>> the first
>> refresh
>> ProcessTripForm.action?originCity=%26%23xCE%3B%26%23x97%3B%26%23xCF%3B
>> %26%23x81%3B%26%23xCE%3B%26%23xAC%3B and continues to expand).
>>
>> My question is how can I preserve data when I use the execAndWait
>> interceptor and use a
>> POST request in a way that when I'm on result page and hit refresh the
>> same
>> request will
>> be repeated?
>> If that is not possible, and I have the data on my URL via GET and
>> includeParams then what
>> do I have to do so encoding does not fail ?
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: ExecAndWait interceptor parameters lost
Posted by Alex Rodriguez Lopez <al...@flordeutopia.pt>.
Hi,
you can store data in session and retrieve it later on. Data stored in
session is persisted through requests.
ActionContext.getContext().getSession();
http://struts.apache.org/2.1.8.1/struts2-core/apidocs/com/opensymphony/xwork2/ActionContext.html
> Hi,
>
> I have an issue in my code that I can't resolve and I would appreciate your
> help.
> I am using the struts2 execAndWait interceptor when I submit a form on my
> site.
> Below is the relevant struts.xml snippet
>
> <interceptor-stack name="loadingStack">
> <interceptor-ref name="defaultStack" />
> <interceptor-ref name="execAndWait" />
> </interceptor-stack>
>
> <action name="ProcessTripForm" class="actions.ProcessTripForm">
> <interceptor-ref name="loadingStack"></interceptor-ref>
> <result name="input">/jsp/unscheduled.jsp</result>
> <result name="success" type="chain">ProcessTrips</result>
> <result name="wait">/jsp/wait.jsp</result>
> </action>
>
> <action name="ProcessTrips"
> class="actions.ProcessTrips">
> <result name="success">/jsp/results.jsp</result>
> <result
> name="noFilteredResults">/jsp/emptyFilteredResults.jsp</result>
> <result name="none">/jsp/no_results.jsp</result>
> </action>
>
> The problem I have, is that when I submit my form via POST and produce
> some results then if I try to refresh the results page (results.jsp) those
> data previously
> send via POST do not exist anymore, so I'm redirected to the wait page and
> finally because data do not exist to an error page (that does not happen in
> Firefox where data somehow are preserved in refresh). Obviously data are
> erased
> the first time the wait page is auto-refreshed. FYI here is a simplified
> version
> of my wait.jsp
>
> <html xmlns="http://www.w3.org/1999/xhtml">
>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <meta http-equiv="refresh" content="3;<s:url includeParams="all"/>"/>
>
> <title>Wait Page</title>
> </head>
>
> <body>
>
> <div>
> <p>Waiting...</p>
> </div>
>
> </body>
> </html>
>
> I could solve this problem by using includeParams="all" in s:url (as seen
> above) when
> refreshing wait page but then the data are seen in the URL (aside the fact
> that there is
> a ton of data).Also, when data are not latin characters then after the first
> refresh the
> character encoding in URL fails, so cannot be used later for repeating the
> request with
> refresh (e.g. ProcessTripForm.action?originCity=Ηράκλειο is becoming after
> the first
> refresh
> ProcessTripForm.action?originCity=%26%23xCE%3B%26%23x97%3B%26%23xCF%3B
> %26%23x81%3B%26%23xCE%3B%26%23xAC%3B and continues to expand).
>
> My question is how can I preserve data when I use the execAndWait
> interceptor and use a
> POST request in a way that when I'm on result page and hit refresh the same
> request will
> be repeated?
> If that is not possible, and I have the data on my URL via GET and
> includeParams then what
> do I have to do so encoding does not fail ?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: ExecAndWait interceptor parameters lost
Posted by Yiorgos Panayiotakis <y....@gmail.com>.
Thanks Dale, that was a very informative mail. I used chain result type just
for a better separation of actions and till
now it did not seem to have any undesirable effect. Anyway I 'll try a new
approach to the problem and I 'll avoid using
chain result type. Thanks all for the help.
On Wed, May 5, 2010 at 5:55 PM, Dale Newfield <da...@newfield.org> wrote:
> I believe that your problem isn't with execAndWait -- it's with the chain
> result type. The way that execAndWait works is that there's only one job
> runnable at a time in any given session with any given action name. The
> intermediate requests don't need the arguments as it's just using the action
> name to look up the already-running action. The original thread is
> continuing to run and should still have the parameter values from the
> launching request. When it completes the next matching request to come in
> will be handled with the original (launching) action instance. This means
> that the intermediate "Is it done yet?" requests don't need any parameters.
> I've basically always found that the chain result type causes many more
> problems than it solves. Any reason you can't just make the SUCCESS result
> for the execAndWait action the same as what you currently have as the
> SUCCESS result for your chained action?
>
> -Dale
>
Re: ExecAndWait interceptor parameters lost
Posted by Dale Newfield <da...@newfield.org>.
I believe that your problem isn't with execAndWait -- it's with the
chain result type. The way that execAndWait works is that there's only
one job runnable at a time in any given session with any given action
name. The intermediate requests don't need the arguments as it's just
using the action name to look up the already-running action. The
original thread is continuing to run and should still have the parameter
values from the launching request. When it completes the next matching
request to come in will be handled with the original (launching) action
instance. This means that the intermediate "Is it done yet?" requests
don't need any parameters. I've basically always found that the chain
result type causes many more problems than it solves. Any reason you
can't just make the SUCCESS result for the execAndWait action the same
as what you currently have as the SUCCESS result for your chained action?
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org