jQuery in Action, 3rd edition
The moose likes Struts and the fly likes token Session Interceptor + Struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "token Session Interceptor + Struts 2" Watch "token Session Interceptor + Struts 2" New topic

token Session Interceptor + Struts 2

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 761

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

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 761
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jan 07, 2008
Posts: 7
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
I agree. Here's the link: http://aspose.com/file-tools
subject: token Session Interceptor + Struts 2
It's not a secret anymore!