1 Reply Latest reply on Oct 2, 2006 2:54 PM by c-e

    ${variable.member} does not work!

    c-e

      Hi,

      I am exploring Enterprise Java with JBoss 4.0.2 - I am trying to access and trying print out members via the expression language EL and face two problems:

      - access to a scripting variable does not cause an error but also does not print out the variable's content

      - acces to a scoped variable causes an error when requesting the jsp

      Do you have any idea?

      Here is the jsp's source code:

      <%! class Test {
      private int number;
      public int getNumber() { return number; }
      protected void setNumber(int number) { this.number = number; }
      }

      %>

      <%
      Test local = new Test();
      local.setNumber(3);

      application.setAttribute("global", local);
      %>


      <%-- No error but also no output! --%>
      ${local.number}


      <%-- Error!

      ${global.number}

      description:
      The server encountered an internal error () that prevented it from fulfilling this request.

      exception:
      javax.servlet.ServletException: javax.servlet.jsp.el.ELException: An error occurred while getting property "number" from an instance of class org.apache.jsp.sample_jsp$Test
      ...

      root cause:
      java.lang.IllegalAccessException: Class org.apache.commons.el.ArraySuffix can not access a member of class org.apache.jsp.sample_jsp$Test with modifiers "public"
      ...

      --%>

        • 1. Re: ${variable.member} does not work!
          c-e

          Hi, I found the riddle's solution:

          But could anybody tell how to access _jspService's objects via ${object.member}? Is it possible, at all? (Although, I don't think it's necessary.)

          Thanks, Christian


          <%! public class Test {
          private int number;
          public int getNumber() { return number; }
          protected void setNumber(int number) { this.number = number; }
          }

          %>

          <%
          Test local = new Test();
          local.setNumber(3);

          pageContext.setAttribute("local", local);
          application.setAttribute("global", local);
          %>

          ${local.number}
          ${global.number}


          Problem A)
          - it seems, that ${object.member} can't access the objects in the _jspService() method
          - but it searches the pageContext object

          Problem B)
          - class must be public
          (the error message -- it just says "public", nothing specific)