It's not a secret anymore!
The moose likes JSP and the fly likes Problem with JSTL functions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem with JSTL functions" Watch "Problem with JSTL functions" New topic

Problem with JSTL functions

Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
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

Joined: Jan 10, 2002
Posts: 63865

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 ]

[Asking smart questions] [About Bear] [Books by Bear]
Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
Thanks a lot,man!
I agree. Here's the link:
subject: Problem with JSTL functions
jQuery in Action, 3rd edition