0
<s:property value="%{sourceName}"/>  
<input type="text" name="sourceName" size="40" maxlength="25000" id="sourceName" class="gray" value="%{sourceName}"/>

<s:property> prints the string present in sourceName, but unable to set the value attribute for textfield to sourceName.

Why is it that I am able to access value from value stack at some places and not at others?

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
Abhijeet
  • 266
  • 1
  • 3
  • 13

1 Answers1

1

Because %{} is an OGNL notation, and hence can be used in Struts tags only.

The other one, in a simple HTML tag, should be a JSP EL notation, ${} (or printed with the whole <s:property /> tag).

BTW Struts tags (and/or JSTL tags) are usually preferred to plain JSP EL because of different reasons, including security.

P.S: read this SO answer to better understand the several notations involved.

Community
  • 1
  • 1
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243