Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

token Session Interceptor + Struts 2

 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • 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: 762
  • Mark post as helpful
  • send pies
  • 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.

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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.

 
Anil Kinge
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic