• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please continue the discussion in the original post.
 
We've gotta get close enough to that helmet to pull the choke on it's engine and flood his mind! Or, we could just read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic