You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shoaib Gauhar <sa...@yahoo.com> on 2007/11/29 08:41:44 UTC

Token problem in Struts 2.1

Hello:

I have been trying to migrate from 2.0.8 to 2.1. I had some problems which were solved yesterday (thanks to you guys). But, now i am facing another problem regarding tokenSession. The same piece of code was working in 2.0.8 but is not working in 2.1. Actually it does work but at the sametime throws an exception on the server. It says something like this.

expr: struts.token val: [Ljava.lang.String;@17aa55b context: ognl.OgnlContext@9a
843dcb root:[com.xyz.action.test@190dc79, com.opensymphony.xwork2.DefaultText
Provider@53a9d5] value: [Ljava.lang.String;@17aa55b
ognl.OgnlException: source is null for getProperty(null, "token")

My actionClass is

public class test extends ActionSupport
{
    public String execute()
    {
        ActionContext.getContext().getSession().put("time",new java.util.Date());
        return SUCCESS;
    }
}

My struts.xml is

            <action name="TestDefaultAction" class="com.xyz.action.test" method="input">
                                        <interceptor-ref name="defaultStack"/>
                                    <result name="input">/WEB-INF/jsp/xyz/test.jsp</result>
          </action>
            <action name="TestInsertAction" class="com.xyz.action.test">
                                    <result name="input">/WEB-INF/jsp/xyz/test.jsp</result>
                                        <result name="error">/WEB-INF/jsp/xyz/test.jsp</result>
                                        <result name="success" type="redirect">/WEB-INF/jsp/xyz/test.jsp</result>
                                        <interceptor-ref name="defaultStack"/>
            <interceptor-ref name="tokenSession"/>
            <result name="invalid.token">/WEB-INF/jsp/xyz/test.jsp</result>
                                      <result>/WEB-INF/jsp/xyz/test.jsp</result>
          </action>

and my test.jsp is

<s:form name="frmFormBuilder" action="TestInsertAction.action" method="POST">
 <s:token />
 <s:submit />
 </s:form>

As the code shows that it is quite a simple scenario. But, i dont know why it is throwing errors. Your guidance is needed.

Regards,

Shoaib Ahmad


      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org