This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes using saveToken() and isTokenValid() methods in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "using saveToken() and isTokenValid() methods in struts" Watch "using saveToken() and isTokenValid() methods in struts" New topic
Author

using saveToken() and isTokenValid() methods in struts

Madhu Bompaly
Greenhorn

Joined: Oct 11, 2007
Posts: 17
Hi every one,

Iam using struts in my application,
whenever I clicked on the refresh button of the browser the form is getting submitted twice.
I tried to use saveToken() and isTokenVaild() methods but still, the form is getting submitted when I click on the Refresh button.
please see my code below.

please let me know what is wrong with my code.

Thanks,
Madhu.

public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

String forward = Constants.FWD_SUCCESS;
String action = mapping.getPath();

HttpSession session = request.getSession();

if(action.equals("/EdisTrees")){


EdisTreesHelper treeHelper = new EdisTreesHelper();

if(!isTokenValid(request)){
treeHelper.processTreesDeatils(mapping, form, request, response);
resetToken(request);
}else{
//do nothing;
}
}
saveToken(request);
return mapping.findForward(forward);

}
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Are you calling saveToken in the action that initially displays the page? Does your page have an html:form tag? If you look at the generated html source (view source) you should see a hidden field that contains the token id.

- Brent
 
Consider Paul's rocket mass heater.
 
subject: using saveToken() and isTokenValid() methods in struts
 
Similar Threads
How do I use tokens to prevent user from multiple submission
Actions executed three times
form resubmission
Prob while refresh the page in weblogic8.1 workshop
saveToken & isTokenValid don't work