Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Struts tokens to do this?

 
A Harry
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a very simple web app - a page to allow users to select various report selection criteria, the other displays the criteria results with a button which puts them back to the search criteria page i.e calls the app startup action!
2 problems -
1. To prevent users bookmarking the report page.
2. To allow users to use the "back" button from the report results page, make ADDITIONAl changes & redisplay the results.
For the the bookmarking problem I have this code forcing them back to the start of the application which works fine -
if(!isTokenValid(request))
{
return (mapping.findForward("invalidAccess"));
}
But I'm stuck on the "back" button one, if I make selections, display the report, click "back", make a change & try to show reports page I get redirected back to start of app as the isTokenValid() fails
Can I get around this? - it's annoying to the users to have to redo all the selections each time!
thanks - hopefully not to badly explained?
harry
This works well! - but
 
Ray Stojonic
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Struts token mechanism is designed to prevent people from double submitting by submitting, clicking back, then submitting again.
You want to use it to do the opposite of what it was intended for, no wonder you're having trouble
A simple solution for this might be to include on the selection form a hidden field like <input type='hidden' name='valid' value='true'> then check for it in your report action. Instead of isTokenValid(), use something like if( request.getParameter("valid") != null ). Unless the request is coming from your selection page, the 'valid' param won't be there.
[ January 08, 2004: Message edited by: Ray Stojonic ]
 
A Harry
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers for that Ray, works brilliantly, got a bit confused with the token stuff but as normal resolutions are often very simple!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic