In your DispatchTestAction class, after you populate the form bean
(request.setAttribute), call saveToken(request) ;

In your DoAction class, before you submit to database, check token
isTokenValid(request); if valid, continue process and resetToken(request);
otherwise, return a global forward which will forward your request to an
error page.

One thing you might change in your DoAction class is not to reload jsp,
instead, forward to DispatchTestAction class so that DispatchTestAction
class saves a new token for next submission.

I usually use a BaseAction class to save token, check token and reset token.
What my execute method looks like:

if (!validateLogin(request))
        return mapping.findForward(getForwardError());
if (!validateTxnToken(mapping, request)) <= check token
        return mapping.findForward(getForwardError());
if (!validateActionForm(form, request))
        return new ActionForward(mapping.getInput());

try
{
        ActionForward forward =
                performPostValidationAction(mapping, form, request,
response);
        handleTxnToken(mapping, request); <= save or reset token
        return forward;
}
catch (Exception ex)
{
        validateInternal(true, "err.unexpected", request);
        return new ActionForward(mapping.getInput());
}




Regards,
 
 
PQ
 
"This Guy Thinks He Knows Everything"
"This Guy Thinks He Knows What He Is Doing"

-----Original Message-----
From: Ashish Kulkarni [mailto:[EMAIL PROTECTED]] 
Sent: February 4, 2003 2:56 PM
To: Struts Users Mailing List
Subject: RE: using tokens in struts, 

Hi PQ,

Suppose this is my scenarion,
dispatchTest.do --- > update.jsp (on submit) --->
doAction.do (on success) -->update.jsp 
dispatchTest.do populates the form bean and passes it
to update.jsp , which displays the data for the user
to change, and then press submit , which will call
doAction class which will update the database and
forward the request to update.jsp, 
So where should i put the saveToken(request) and where
should i test isValidToken(request)
Also is there some thing i need to define in
struts-config.xml for it

Ashish

--- [EMAIL PROTECTED] wrote:
> Token works perfect for my app.
> 
> In my "load" action, I set token by
> saveToken(request).
> 
> In my "submit" action, I check token by
> isTokenValid(request); if invalid, I
> forwards request to an error page.
> 
> Very simple.
> 
> Regards,
>  
>  
> PQ
>  
> "This Guy Thinks He Knows Everything"
> "This Guy Thinks He Knows What He Is Doing"
> 
> -----Original Message-----
> From: Ashish Kulkarni
> [mailto:[EMAIL PROTECTED]] 
> Sent: February 4, 2003 1:57 PM
> To: [EMAIL PROTECTED]
> Subject: using tokens in struts, 
> 
> Hi,
> I was trying to get a example which shows how to use
> tokens in struts, yesterday i got a previous post
> from
> this forum, so i tried it and it did not work for me
> I am using struts1.1b2
> Does any one has used token to avoid multiple
> submits??
> if so can u post some example or some article where
> i
> can get the info
> the ose which i got was 
>
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg52700.html
> 
> need help
> 
> 
> =====
> A$HI$H
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up
> now.
> http://mailplus.yahoo.com
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


=====
A$HI$H

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to