• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Stop multiple posts

 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know that this has been posted several times. I have read all the posts and I still can't get it to work properly.

I have the following in struts-config.xml


In SetupFormAction



What am I doing wrong? Thank you all for your time.

In ProcessFormAction



In my jsp I had to include like another person who posted the following otherwise it would never work.

 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The whole point of checking the validity of the token wth isTokenValid is to avoid doing any processing if the token is not valid and process the action only if the token is valid. So, your code should look something like this:
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont think you need to manually set the Token in the Jsp. Struts would do it automatically for you. The only thing you need to do is to check the validity of the Token in the Action class as specified in the above post.
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand that I don't need to manually set the token in my page. If I dont do that the isTokenValid(request) method always returns false. In SetupFormAction I query DB to obtain data to display on page I then call saveToken(request); and I lastly I forward to jsp. ProcessFormAction is called if user submits changes to the data by clicking submit in the jsp. It checks isTokenValid(request). If it is, it saves changes to DB and forwards back to SetupFormAction. If the token is not valid it simply forwards back to SetupFormAction. My problem is that isTokenValid(request) always returns false. Once I included the code below it works.



Im handling the setup in one action and the save in another action could this be a problem?
[ December 02, 2006: Message edited by: john mattucci ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does your forward from the setupFormAction specify redirect="true"? If so, that's the problem. If redirect="true" is specified, a message is sent to the browser to redirect to the JSP, meaning the display of the JSP occurs in a different request than the setupFormAction. A token is good only for one request.
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No my forward from the setupFormAction does not specify redirect="true". My struts-config contains the following


[ December 03, 2006: Message edited by: john mattucci ]
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmm...Is your jsp using an html:form tag? If you have called saveToken in your setup action and you are using a html:form tag then a hidden input value will be generated for you. If you view the source in your browser you should see something like this:


I'm handling the setup in one action and the save in another action could this be a problem?


No, that is the way it is supposed to work.

- Brent
 
reply
    Bookmark Topic Watch Topic
  • New Topic