• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to access this variable

 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I defined a variable (I know it is not a very good practice, but let's say I need to).
<% String var = ..... %>

<s:if test="var.startsWith('xyz')=='true'">
...
</s:if>

It seems I can not access this var in the <s:if> tag. What syntax did I use wrong ?

Thanks.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OGNL expressions look on the value stack. Scriptlet variables are not on the value stack. The *easiest* thing to do would be to put the scriptlet variable into a JEE scope (page or request, probably): OGNL expressions *can* access scoped variables.

Really, though, this is a Bad Idea, and there's almost *never* an absolute need to do this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic