• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using saveToken() and isTokenValid() methods in struts

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);

}
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic