Tags:
Apache Struts 2, struts 2, 2, Issue in using <s:token> tag, Java - Struts 2, Unexpected Exception caught setting 'struts.token', Issue in using token-session
Hi,
I'm trying to use struts 2 token-session interceptor to handle the double submissions in my application.
Here is my action class signature: public class BusinessAction extends BaseAction implements Preparable while the BaseAction extends ActionSupport implements SessionAware.
Please note that when the token interceptor captures the invalid token i want the 'view' action to be invoked which is the same action that is invoked after a proper submission. After a normal submission the application will go to the view page. When the user does a double submission I want the application to show the view page of the first submission and ignore the further submissions.
In my input jsp page I've included the <s:token/> under the <s:form> tag.
This set up has successfully avoided the issue of submitting agian after pressing the browser back button.
But, when I submit once and then again before the process gets completed, the application breaks throwing the following error:
com.opensymphony.xwork2.interceptor.ParametersInterceptor setParameters ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'struts.token' on 'class com.paribas.wlist.action.BusinessAction: Error setting expression 'struts.token' with value '[Ljava.lang.String;@44304430' com.opensymphony.xwork2.interceptor.ParametersInterceptor setParameters ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'struts.token.name' on 'class com.paribas.wlist.action.BusinessAction: Error setting expression 'struts.token.name' with value '[Ljava.lang.String;@43944394'
And then it throws a null pointer exception:
WebApp E [Servlet Error]-[<null>]: java.lang.NullPointerException at com.ibm.ws.webcontainer.srt.SRTServletRequest$SRTServletRequestHelper.access$200(SRTServletRequest.java:2045) at com.ibm.ws.webcontainer.srt.SRTServletRequest.getAttribute(SRTServletRequest.java:186)
I know I'm missing something, but couldn't figure out what it is. Could you please help me this issue.
Not exactly sure what you are trying to accomplish. Are you trying to prevent double clicking on submit button?
The easiest way to avoid this, is to write javascript function to disable the submit button on the first click. Or if you can just make the submit button invisible after first click.