Search code examples
jspstrutsel

Can I convert <bean:write> to EL in Struts?


If I'm not mistaken, in Struts 1.3 these three expressions are equivalent:

<bean:write name="form" property="foo" />

<c:out value="${form.foo}" />

${form.foo}

Are there any differences? The only one I've found is that <c:out> escapes XML output, and ${} doesn't. No idea about <bean:write>, it says here that it searches the form property in the page context, then in the request, then in the session... but I guess <c:out> and ${} do that, too.

Now... what would this expression do?

<bean:write name="${form}" property"foo" />

My guess is that the ${form} part gets evaluated first, then it finds wathever object was named in the form variable, and recovers its foo property. If that's in fact what it does... can I convert it to an EL? Something like this, but actually working:

${${form}.foo}

Solution

  • Self answering the last question:

    According to this and this, I believe that I could use <bean:define> in this way:

    <bean:define id="blarg" name="${form}" property="foo" />
    

    And then this would become available:

    ${blarg}
    

    I still haven't tested it though.