• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL 1.0 - Get value of from an object when fn cannot be used

 
Sam Gehouse
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I get the value from the method of an Object (e.g., length of a String by calling myString.length()) and set the value of the length to a variable?

In the code below, my objective is to set myVar with the length() value obtained from myString of myForm object.

Code is somewhat like:

<c:choose>
<c:when test="${someCondition}">
<c:set var="${myVar}" value="${myForm.myString}"></c:set>
</c:when>
<!-- More <c:when> conditions -->
</c:choose>

myForm is an object which has myString as attribute with corresponding public getter and setter methods.

I get syntax error if "${myForm.myString}" is replaced with value="${myForm.myString.length}

I want to get the length of myString and set that value to myVar for future use in JSP.

Is there a work-around if I cannot use fn? I cannot use fn:length() as I am advised because of the level of JSp support
Any help will be appreciated.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please continue the discussion in the original post.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic