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

token Session Interceptor + Struts 2

 
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am trying to use struts 2 token session interceptor

Bellow is part of my struts.xml



I have 2 jsp clientForm.jsp which has 3 input field. on submit of clientForm.jsp data goes into database and control go to client.jsp

which display all the records from the table.

Things were working fine before i configured token-session but when user refreshes the browser page duplicate records were gettin inserted so i thought of using token-session interceptor.

But after configuring token-session interceptor i am not able to insert record in database.

bellow is the warning which i am getting on Console



I have added the bellow tags in my clientForm.jsp and client.jsp



Am i using token-session at right place ?

What's the reason of the warning which i am getting.

 
Jigar Naik
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have shofted

<s:token/> inside <s:form> tag and things worked fine. but i didn't really understand the reason.

one more thing why i have to specifiy

<s:token/> in both the form ?

clientForm.jsp and client.jsp

If i remove it from any of the form i get following stack trace.

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looking at the generated HTML will answer your first question as to why the <s:token/> tag must be inside the form. Plus the docs state:

Note: To set a token in your form, you should use the token tag. This tag is required and must be used in the forms that submit to actions protected by this interceptor.


Note the "in the forms" part.

You're using the "token-session" interceptor; if you're only trying to protect a single form try using the "token" interceptor.

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
I am new to strut2,wanted to know more about Session Interceptor, specifically the action code to avoid multiple submit. will you please help to get some code sample or any. Thanks in advance
 
keep an eye out for scorpions and black widows. But the tiny ads are safe.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic