title: OGNL Array and List Indexing
body: <p>I'm sending this parameter to my struts action </p>
  
  <blockquote>
    <p>cdata[1]=bar</p>
  </blockquote>
  
  <p>In my action I'm interested in the index and the value.
  I defined a getter/setter pair for <code>CDATA</code> as the <a href="http://commons.apache.org/proper/commons-ognl/language-guide.html#Indexing" rel="nofollow">OGNL documentation</a> suggests:</p>
  
  <pre><code>public void setCdata(int index, String value){
      LOG.info("setData; key="+ key +"; value="+ value);
      // store index and value;
  }
  
  public String getCdata(int index){
      return null; // don't really need a setter
  }
  </code></pre>
  
  <p>This is the Exception I get:</p>
  
  <pre><code>2013-04-29 15:38:49,792 [http-apr-8080-exec-3] WARN  com.opensymphony.xwork2.util.logging.commons.CommonsLogger.warn(CommonsLogger.java:60) - Error setting expression 'cdata[1]' with value '[Ljava.
  lang.String;@4223d2a4'
  ognl.OgnlException: target is null for setProperty(null, "1", [Ljava.lang.String;@4223d2a4)
          at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2309)
          at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
          at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
          at ognl.SimpleNode.setValue(SimpleNode.java:301)
          at ognl.ASTChain.setValueBody(ASTChain.java:227)
          at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
          at ognl.SimpleNode.setValue(SimpleNode.java:301)
          at ognl.Ognl.setValue(Ognl.java:737)
          ...
  </code></pre>
  
  <p>If I define a public member variable <code>String[] cdata = new String[1000]</code> I don't see any exception in my log but my setter is not called either. If the member variable is private I get another exception again.</p>