• 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

saveToken, isTokenValid, resetToken

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK everyone, I will do my best to describe my problem but bear with me. I am using struts tokens to stop double submit of a jsp page.

// Before the page first loads this statement runs in a different Action:
resetToken(request);

// Next in the actions execute method the code goes like follows:
...
String result = StringConstants.SUCCESS;
if (isTokenValid(request))
{
resetToken(request);
Properties prop = new Properties();
BeanUtils.copyProperties(prop,form);
String selected = prop.getSelected();
String navigation = prop.getNavigation();
if (selected.equals(StringConstants.NEXT)){
result = executeNext(mapping,request, prop);
}
else if (selected.equals(StringConstants.PREVIOUS)){
result = executePrevious(mapping,request);
}
else if (selected.equals(StringConstants.FINALIZE)){
result = executeFinalize(mapping,request, prop);
}
}
// Now I do some catch statements which have been omitted
// next I reset the token and return the result
saveToken(request);
return mapping.findForward(result);

findForward will forward me back to the same page when executeNext or executePrevious is called. When the first request comes in it checks to see if the token is valid. It is valid, so it starts processing (executeNext for example). While the first request is processing, the second request comes in. The token is not valid (as it has been reset), so it skips everything that modifies the state of the application, goes to the end, executes saveToken and returns success (exactly what we want it to do!!!). Next the first request finishes processing and returns success but by then the jsp page has already reloaded by the second request. The jsp page doesnt reload and nothing happens. This is bad.

I need either a) the first request to return first or b) the second request to return something that wont reload the jsp page. Here is an exerpt from my struts-config:

<action path="/configure"
name="configureForm"
type="com.omitted.configurator.view.configure.ConfigureAction"
scope="request" unknown="false">
<forward name="success" path="Tiles.ConfigurationPage" />
<forward name="finalize" path="Tiles.QuotePage" />
<forward name="failure" path="/WEB-INF/jsp/badLoginForm.jsp" />
</action>

I sure hope you understand :-). Please help.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this : http://www.javaworld.com/javaworld/javatips/jw-javatip136.html
 
Get off me! Here, read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic