title: Struts2: Malformed OGNL expression
body: <p>In my JSPs, I'm using a plugin named <a href="http://tagedit.webwork-albrecht.de/" rel="nofollow">TagEdit</a>, It has to have an input text field with " name='tag[]' " like below:</p>
  
  <pre><code>&lt;s:form theme="simple" action="myActionn" method="post"&gt;
      &lt;s:textfield theme="simple" name="tag[]" value="" cssClass="tag"/&gt;
      &lt;sj:submit targets="actionMessageResult"/&gt;
  &lt;/s:form&gt;
  </code></pre>
  
  <p>But when I submit it, struts2 throws this exception:</p>
  
  <pre><code>WARNING: Error setting expression 'tag[]' with value '[Ljava.lang.String;@6c2a78'
  ognl.ExpressionSyntaxException: Malformed OGNL expression: tag[] [ognl.ParseException: Encountered " "]" "] "" at line 1, column 5.
  Was expecting one of:
      ":" ...
      "not" ...
      "+" ...
      "-" ...
      "~" ...
      "!" ...
      "(" ...
      "true" ...
      "false" ...
      "null" ...
      "#this" ...
      "#root" ...
      "#" ...
      "[" ...
      "{" ...
      "@" ...
      "new" ...
      &lt;IDENT&gt; ...
      &lt;DYNAMIC_SUBSCRIPT&gt; ...
      "\'" ...
      "`" ...
      "\"" ...
      &lt;INT_LITERAL&gt; ...
      &lt;FLT_LITERAL&gt; ...
      ]
      at ognl.Ognl.parseExpression(Ognl.java:112)
      at com.opensymphony.xwork2.ognl.OgnlUtil.compile(OgnlUtil.java:225)
      at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:209)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:173)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:160)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:151)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:292)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:203)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:192)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
      at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:510)
      at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      at java.lang.Thread.run(Unknown Source)
  Caused by: ognl.ParseException: Encountered " "]" "] "" at line 1, column 5.
  Was expecting one of:
      ":" ...
      "not" ...
      "+" ...
      "-" ...
      "~" ...
      "!" ...
      "(" ...
      "true" ...
      "false" ...
      "null" ...
      "#this" ...
      "#root" ...
      "#" ...
      "[" ...
      "{" ...
      "@" ...
      "new" ...
      &lt;IDENT&gt; ...
      &lt;DYNAMIC_SUBSCRIPT&gt; ...
      "\'" ...
      "`" ...
      "\"" ...
      &lt;INT_LITERAL&gt; ...
      &lt;FLT_LITERAL&gt; ...
  
      at ognl.OgnlParser.generateParseException(OgnlParser.java:3172)
      at ognl.OgnlParser.jj_consume_token(OgnlParser.java:3051)
      at ognl.OgnlParser.unaryExpression(OgnlParser.java:1236)
      at ognl.OgnlParser.multiplicativeExpression(OgnlParser.java:971)
      at ognl.OgnlParser.additiveExpression(OgnlParser.java:894)
      at ognl.OgnlParser.shiftExpression(OgnlParser.java:750)
      at ognl.OgnlParser.relationalExpression(OgnlParser.java:508)
      at ognl.OgnlParser.equalityExpression(OgnlParser.java:405)
      at ognl.OgnlParser.andExpression(OgnlParser.java:352)
      at ognl.OgnlParser.exclusiveOrExpression(OgnlParser.java:299)
      at ognl.OgnlParser.inclusiveOrExpression(OgnlParser.java:246)
      at ognl.OgnlParser.logicalAndExpression(OgnlParser.java:193)
      at ognl.OgnlParser.logicalOrExpression(OgnlParser.java:140)
      at ognl.OgnlParser.conditionalTestExpression(OgnlParser.java:101)
      at ognl.OgnlParser.assignmentExpression(OgnlParser.java:64)
      at ognl.OgnlParser.expression(OgnlParser.java:23)
      at ognl.OgnlParser.index(OgnlParser.java:2336)
      at ognl.OgnlParser.navigationChain(OgnlParser.java:1331)
      at ognl.OgnlParser.unaryExpression(OgnlParser.java:1196)
      at ognl.OgnlParser.multiplicativeExpression(OgnlParser.java:971)
      at ognl.OgnlParser.additiveExpression(OgnlParser.java:894)
      at ognl.OgnlParser.shiftExpression(OgnlParser.java:750)
      at ognl.OgnlParser.relationalExpression(OgnlParser.java:508)
      at ognl.OgnlParser.equalityExpression(OgnlParser.java:405)
      at ognl.OgnlParser.andExpression(OgnlParser.java:352)
      at ognl.OgnlParser.exclusiveOrExpression(OgnlParser.java:299)
      at ognl.OgnlParser.inclusiveOrExpression(OgnlParser.java:246)
      at ognl.OgnlParser.logicalAndExpression(OgnlParser.java:193)
      at ognl.OgnlParser.logicalOrExpression(OgnlParser.java:140)
      at ognl.OgnlParser.conditionalTestExpression(OgnlParser.java:101)
      at ognl.OgnlParser.assignmentExpression(OgnlParser.java:64)
      at ognl.OgnlParser.expression(OgnlParser.java:23)
      at ognl.OgnlParser.topLevelExpression(OgnlParser.java:15)
      at ognl.Ognl.parseExpression(Ognl.java:110)
      ... 52 more
  /-- Encapsulated exception ------------\
  ognl.ParseException: Encountered " "]" "] "" at line 1, column 5.
  Was expecting one of:
      ":" ...
      "not" ...
      "+" ...
      "-" ...
      "~" ...
      "!" ...
      "(" ...
      "true" ...
      "false" ...
      "null" ...
      "#this" ...
      "#root" ...
      "#" ...
      "[" ...
      "{" ...
      "@" ...
      "new" ...
      &lt;IDENT&gt; ...
      &lt;DYNAMIC_SUBSCRIPT&gt; ...
      "\'" ...
      "`" ...
      "\"" ...
      &lt;INT_LITERAL&gt; ...
      &lt;FLT_LITERAL&gt; ...
  
      at ognl.OgnlParser.generateParseException(OgnlParser.java:3172)
      at ognl.OgnlParser.jj_consume_token(OgnlParser.java:3051)
      at ognl.OgnlParser.unaryExpression(OgnlParser.java:1236)
      at ognl.OgnlParser.multiplicativeExpression(OgnlParser.java:971)
      at ognl.OgnlParser.additiveExpression(OgnlParser.java:894)
      at ognl.OgnlParser.shiftExpression(OgnlParser.java:750)
      at ognl.OgnlParser.relationalExpression(OgnlParser.java:508)
      at ognl.OgnlParser.equalityExpression(OgnlParser.java:405)
      at ognl.OgnlParser.andExpression(OgnlParser.java:352)
      at ognl.OgnlParser.exclusiveOrExpression(OgnlParser.java:299)
      at ognl.OgnlParser.inclusiveOrExpression(OgnlParser.java:246)
      at ognl.OgnlParser.logicalAndExpression(OgnlParser.java:193)
      at ognl.OgnlParser.logicalOrExpression(OgnlParser.java:140)
      at ognl.OgnlParser.conditionalTestExpression(OgnlParser.java:101)
      at ognl.OgnlParser.assignmentExpression(OgnlParser.java:64)
      at ognl.OgnlParser.expression(OgnlParser.java:23)
      at ognl.OgnlParser.index(OgnlParser.java:2336)
      at ognl.OgnlParser.navigationChain(OgnlParser.java:1331)
      at ognl.OgnlParser.unaryExpression(OgnlParser.java:1196)
      at ognl.OgnlParser.multiplicativeExpression(OgnlParser.java:971)
      at ognl.OgnlParser.additiveExpression(OgnlParser.java:894)
      at ognl.OgnlParser.shiftExpression(OgnlParser.java:750)
      at ognl.OgnlParser.relationalExpression(OgnlParser.java:508)
      at ognl.OgnlParser.equalityExpression(OgnlParser.java:405)
      at ognl.OgnlParser.andExpression(OgnlParser.java:352)
      at ognl.OgnlParser.exclusiveOrExpression(OgnlParser.java:299)
      at ognl.OgnlParser.inclusiveOrExpression(OgnlParser.java:246)
      at ognl.OgnlParser.logicalAndExpression(OgnlParser.java:193)
      at ognl.OgnlParser.logicalOrExpression(OgnlParser.java:140)
      at ognl.OgnlParser.conditionalTestExpression(OgnlParser.java:101)
      at ognl.OgnlParser.assignmentExpression(OgnlParser.java:64)
      at ognl.OgnlParser.expression(OgnlParser.java:23)
      at ognl.OgnlParser.topLevelExpression(OgnlParser.java:15)
      at ognl.Ognl.parseExpression(Ognl.java:110)
      at com.opensymphony.xwork2.ognl.OgnlUtil.compile(OgnlUtil.java:225)
      at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:209)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:173)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:160)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:151)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:292)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:203)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:192)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
      at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:510)
      at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      at java.lang.Thread.run(Unknown Source)
  \--------------------------------------/
  </code></pre>
  
  <p>The struts.xml:</p>
  
  <pre><code>    &lt;package name="default" extends="struts-default" &gt;
          &lt;interceptors&gt;
              &lt;interceptor-stack name="defaultStack"&gt;
                  &lt;interceptor-ref name="params"&gt;
                      &lt;param name="excludeParams"&gt;^tag\..*&lt;/param&gt;
                  &lt;/interceptor-ref&gt;
              &lt;/interceptor-stack&gt;
          &lt;/interceptors&gt;
  
          &lt;action name="myActionn" class="com.fap.controller.common.tagAction"&gt;
              &lt;result name="success"&gt;ajax_result/common/actionMessage/action_message_result_error.jsp&lt;/result&gt;
              &lt;result name="error"&gt;ajax_result/common/actionMessage/action_message_result_error.jsp&lt;/result&gt;
          &lt;/action&gt;
  
      &lt;/package&gt;
  </code></pre>
  
  <p>And the action:</p>
  
  <pre><code>public class tagAction extends ActionSupport {
  
      private static final long serialVersionUID = 1L;
  
      public String execute() {
          try {
              Map params = (Map) ActionContext.getContext().getParameters();
  
              String[] entries1 = (String[]) params.get("tag[3-a]");
              String[] entries2 = (String[]) params.get("tag[]");
              for(int i=0;i&lt;entries1.length;i++)
                  System.out.println(entries1[i]);
              for(int i=0;i&lt;entries2.length;i++)
                  System.out.println(entries2[i]);
  
  
          } catch (Exception e) {
              addActionError(e.getMessage());
              e.printStackTrace();
              return "error";
          }
          return "success";
      }
  }
  </code></pre>
  
  <p>what should I do buddies?
  thank you all</p>