You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Arpan <ar...@gmail.com> on 2014/06/17 12:49:54 UTC
struts 2: Redirect action giving token issue
HI All,
We have two pages and both of them have <s:token> tag and both of them use
token interceptor.
After I submit one form I need to display another form in another page.
I am using "redirectAction" to redirect
Before redirecting in the first action class I am setting token value into
session.
But when it tries to redirect to the 2nd action.. the error is getting
displayed.
"Could not find token name in params."
How to pass the token in the parameter..How to solve this problem...any
help would be precious.
Thanks
Arpan
Re: struts 2: Redirect action giving token issue
Posted by Arpan <ar...@gmail.com>.
Thanks a lot Christoph..
It was a very good hint.
Ultimately I have added the token value into request attribute and then
accessed it in the result param as follows :
<param name="struts.token.name">token</param>
<param name="token">%{#request.token}</param>
On Tue, Jun 17, 2014 at 6:09 PM, Christoph Nenning <
Christoph.Nenning@lex-com.net> wrote:
> You can use OGNL in result config, like this:
>
>
> <result name="showReportResult" type="redirect-action">
> <param name="actionName">generateReport</param>
> <param name="struts.token.name">foo</param>
> <param name="foo">${token}</param>
> </result>
>
>
>
>
> Regards,
> Christoph
>
>
>
>
>
> > Hi Christoph,
> >
> > There are token checks while submitting the ist page and while
> displaying
> > the 2nd page also.
> > The real problem is that while redirecting token is getting cleared from
> > request parameter. Is there anyway I can pass the token in the request
> > parameter to the next action.
> >
> >
> > On Tue, Jun 17, 2014 at 5:14 PM, Christoph Nenning <
> > Christoph.Nenning@lex-com.net> wrote:
> >
> > > > HI All,
> > > >
> > > > We have two pages and both of them have <s:token> tag and both of
> them
> > > use
> > > > token interceptor.
> > > >
> > > > After I submit one form I need to display another form in another
> page.
> > > > I am using "redirectAction" to redirect
> > > >
> > > > Before redirecting in the first action class I am setting token
> value
> > > into
> > > > session.
> > > > But when it tries to redirect to the 2nd action.. the error is
> getting
> > > > displayed.
> > > > "Could not find token name in params."
> > > >
> > > > How to pass the token in the parameter..How to solve this
> problem...any
> > > > help would be precious.
> > > >
> > > > Thanks
> > > > Arpan
> > >
> > >
> > > token interceptor is not intended to be used for redirects. It is
> intended
> > > to be used with forms. On GET request, when form is shown to user, the
> > > token is generated and on POST request, when user saves, the token is
> > > checked.
> > >
> > >
> > > If you really want to use it with redirects you have to add 2 URL
> > > parameters:
> > >
> > > struts.token.name=<custom name>
> > > <custom name>=<token>
> > >
> > >
> > > Regards,
> > > Christoph
> > >
> > > This Email was scanned by Sophos Anti Virus
> > >
>
> This Email was scanned by Sophos Anti Virus
>
Re: struts 2: Redirect action giving token issue
Posted by Christoph Nenning <Ch...@lex-com.net>.
You can use OGNL in result config, like this:
<result name="showReportResult" type="redirect-action">
<param name="actionName">generateReport</param>
<param name="struts.token.name">foo</param>
<param name="foo">${token}</param>
</result>
Regards,
Christoph
> Hi Christoph,
>
> There are token checks while submitting the ist page and while
displaying
> the 2nd page also.
> The real problem is that while redirecting token is getting cleared from
> request parameter. Is there anyway I can pass the token in the request
> parameter to the next action.
>
>
> On Tue, Jun 17, 2014 at 5:14 PM, Christoph Nenning <
> Christoph.Nenning@lex-com.net> wrote:
>
> > > HI All,
> > >
> > > We have two pages and both of them have <s:token> tag and both of
them
> > use
> > > token interceptor.
> > >
> > > After I submit one form I need to display another form in another
page.
> > > I am using "redirectAction" to redirect
> > >
> > > Before redirecting in the first action class I am setting token
value
> > into
> > > session.
> > > But when it tries to redirect to the 2nd action.. the error is
getting
> > > displayed.
> > > "Could not find token name in params."
> > >
> > > How to pass the token in the parameter..How to solve this
problem...any
> > > help would be precious.
> > >
> > > Thanks
> > > Arpan
> >
> >
> > token interceptor is not intended to be used for redirects. It is
intended
> > to be used with forms. On GET request, when form is shown to user, the
> > token is generated and on POST request, when user saves, the token is
> > checked.
> >
> >
> > If you really want to use it with redirects you have to add 2 URL
> > parameters:
> >
> > struts.token.name=<custom name>
> > <custom name>=<token>
> >
> >
> > Regards,
> > Christoph
> >
> > This Email was scanned by Sophos Anti Virus
> >
This Email was scanned by Sophos Anti Virus
Re: struts 2: Redirect action giving token issue
Posted by Arpan <ar...@gmail.com>.
Hi Christoph,
There are token checks while submitting the ist page and while displaying
the 2nd page also.
The real problem is that while redirecting token is getting cleared from
request parameter. Is there anyway I can pass the token in the request
parameter to the next action.
On Tue, Jun 17, 2014 at 5:14 PM, Christoph Nenning <
Christoph.Nenning@lex-com.net> wrote:
> > HI All,
> >
> > We have two pages and both of them have <s:token> tag and both of them
> use
> > token interceptor.
> >
> > After I submit one form I need to display another form in another page.
> > I am using "redirectAction" to redirect
> >
> > Before redirecting in the first action class I am setting token value
> into
> > session.
> > But when it tries to redirect to the 2nd action.. the error is getting
> > displayed.
> > "Could not find token name in params."
> >
> > How to pass the token in the parameter..How to solve this problem...any
> > help would be precious.
> >
> > Thanks
> > Arpan
>
>
> token interceptor is not intended to be used for redirects. It is intended
> to be used with forms. On GET request, when form is shown to user, the
> token is generated and on POST request, when user saves, the token is
> checked.
>
>
> If you really want to use it with redirects you have to add 2 URL
> parameters:
>
> struts.token.name=<custom name>
> <custom name>=<token>
>
>
> Regards,
> Christoph
>
> This Email was scanned by Sophos Anti Virus
>
Re: struts 2: Redirect action giving token issue
Posted by Christoph Nenning <Ch...@lex-com.net>.
> HI All,
>
> We have two pages and both of them have <s:token> tag and both of them
use
> token interceptor.
>
> After I submit one form I need to display another form in another page.
> I am using "redirectAction" to redirect
>
> Before redirecting in the first action class I am setting token value
into
> session.
> But when it tries to redirect to the 2nd action.. the error is getting
> displayed.
> "Could not find token name in params."
>
> How to pass the token in the parameter..How to solve this problem...any
> help would be precious.
>
> Thanks
> Arpan
token interceptor is not intended to be used for redirects. It is intended
to be used with forms. On GET request, when form is shown to user, the
token is generated and on POST request, when user saves, the token is
checked.
If you really want to use it with redirects you have to add 2 URL
parameters:
struts.token.name=<custom name>
<custom name>=<token>
Regards,
Christoph
This Email was scanned by Sophos Anti Virus