• 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

 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all.

I am trying to use jstl in my jsp.
Below is the code i wanted in jstl form.

I am trying to put this in jstl tag.

I am not able to use charAt the way i have mentioned above.
Is there any other solution for this.

Any help may be appreciated.
Thanks in advance.
Ramya
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quite correct, you can't call java methods like that. EL can only access the getters/setters of an object.

What are you trying to accomplish this for? It might be easier to encapsulate the data in an object.
For instance, if you have a username, and you are wanting to get the first initial of their name then provide two methods on a user object:
getFirstName()
getInitial().

The implementation of getInitial might just return getFirstName().charAt(0);
In JSTL you could then use ${user.firstName}, ${user.initial}

The alternative if you have a JSP2.0 container and can use JSTL1.1 is to use a function.
note: Your first set statement was incorrectly translated from the original java. You should not use the ${ } around a static value.



Cheers,
evnafets
 
meena latha
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.
That was really helpful
reply
    Bookmark Topic Watch Topic
  • New Topic