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.

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.3.15.2
    • Fix Version/s: 2.3.20
    • Component/s: Documentation
    • Labels:
    • Environment:

      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

            • Assignee:
              lukaszlenart Lukasz Lenart
              Reporter:
              Andrea Ligios Andrea Ligios

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment