This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem with JSTL functions" Watch "Problem with JSTL functions" New topic
Author

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 ]

truehh@hotmail.com
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60741
    
  65

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] [Bear's FrontMan] [About Bear] [Books by Bear]
Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
Thanks a lot,man!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with JSTL functions
 
Similar Threads
c:if
c:if and c:choose
Trying to get "contains" to work
jsp:useBean tag Rules
HashMap, contains a key ?