Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4228

OGNL Basic: if AllowStaticMethodAccess is set to true, JSP fragments included with <jsp:include/> can access Action members, otherwise they can't.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Cannot Reproduce
    • 2.3.15.2
    • 2.3.20
    • Documentation
    • JBOSS EAP 6.01, Struts 2.3.15.2

    Description

      Trying to call an Action's getter from an included JSP, I get null:

      MyAction.java
      private String message = "The message I want to read...";
      public String getMessage() { 
          return message; 
      }
      
      main.jsp
      <%@taglib prefix="s" uri="/struts-tags" %>
      <html>
         <head></head>
         <body>
             <div> I'm a DIV in main.jsp </div>           
             <jsp:include page="fragment.jsp" />
         <body>
      </html>
      
      fragment.jsp
      <%@taglib prefix="s" uri="/struts-tags" %>
      <div>
          I'm a DIV from fragment.jsp
          <br/>
          Message from Action: <s:property value="message" />
      </div>
      

      If I set:

      struts.xml
      <constant name="struts.ognl.allowStaticMethodAccess" value="true"/>    
      

      the getter is now reachable.

      This applies only to <jsp:include> ; with <s:include>, the getter is ALWAYS reachable.

      Seems to be some kind of side effect, maybe it should be verified and added to the documentation. Originally posted here.

      Attachments

        Activity

          People

            lukaszlenart Lukasz Lenart
            Andrea Ligios Andrea Ligios
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: