• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with JSTL functions

 
Joshua Cloch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

Here is the problem: suppose i want to check whether string A contains string B.

I may use this funtion: <c:if test="${fn:contains(A, B)}">

If A is a varibles,for example,A is defined as ${param.customerName};B is a constant:tom

The funtion is converted into:

c:if test="${fn:contains('${param.customerName}', 'tom')}">

Problem occurs! The tomcat server wont get the value defined by ${param.customerName},instead,it just treat it as a constant string.

Any ideas?
[ January 11, 2007: Message edited by: Joshua Cloch ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
c:if test="${fn:contains('${param.customerName}', 'tom')}">


Your syntax is hosed.

The ${} notation is used to surround an entire EL expression. It's not some sort of "fetch" operator. They cannot be nested.

Remove the nested ${}.
[ January 11, 2007: Message edited by: Bear Bibeault ]
 
Joshua Cloch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot,man!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic