cancel
Showing results for 
Search instead for 
Did you mean: 

JSTL EL Expression with function calls

Former Member
0 Kudos

There is a problem with JSTL EL Expressions with function calls.

Problem 1: If the function that returns a boolean is preceded by "!" then an exception is raised at runtime.

Ex. <c:if test="${!r:isReady()}">

Problem 2: If the EL expression with a function call is NOT preceded by double-quotes or space then an exception is raised at runtime.

Ex. <c:set var="ab" value="$/$/" />

The above example the second EL expression is preceded by "/".

Does anyone know if these are known problems and/or if there are fixes?

Accepted Solutions (1)

Accepted Solutions (1)

Vlado
Advisor
Advisor
0 Kudos

Hi Enrique,

Can you post the JSP page here?

Former Member
0 Kudos

Thanks for replying.

I will post a sample JSP but first allow me to refine the description of the problems. There are two issues.

Issue 1: related to "c:if" tag and the value parameter of this tag has an EL expression with a tag-function.

Case 1: the EL expression has a "!" as a first character and no space following it, and the "!" is involved in a tag-function.

Example: <c:if value="${!r:isReady()}" />

Case 2: the EL expression has a "!" and it is not the first character, and the "! is involved in a tag-function.

Example: <c:if value="${isInitialized && !r:isReady()}" />

Issue 2: related to "c:set" tag and the value parameter of this tag has an EL expression with a tag-function. The EL expression cannot be preceded by other characters.

Example: <c:set var="a" value="abcd$" />

Example: <c:set var="b" value="$" />

Former Member
0 Kudos

Sample jsp which has both issues:

<%@page session="false" contentType="text/html;charset=utf-8" %>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%@taglib prefix="r" uri="http://www.dummy.com/rumba"%>

<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<%@taglib prefix="tags" tagdir="/WEB-INF/tags"%>

<html>

<head>

<title>$ ($)</title> <link href="${pageContext.request.contextPath}/css" rel="stylesheet" type="text/css"/> </head> <body> <jsp:include page="/www/common/header.jsp" /> <c:set var="msurl" value="$/$/$" />

<h2>

URL: $

</h2>

<div>

<b><fmt:message key="map.sr" />: </b> <tags:spatialReference value="${msi.spatialReference}" f="html" /> <br/><br/>

<c:if test="${!r:tokenBasedSecurity(pageContext.servletContext)}">

<b><fmt:message key="catalog.view-footprints-in" />:</b>

<a href="$$?f=kmz"><fmt:message key="catalog.ge" /></a>

<br/><br/>

</c:if>

</div>

</body>

</html>

former_member185706
Participant
0 Kudos

Enrique,

could you post the exception in both cases ?

Regards

Bojidar

Former Member
0 Kudos

For both situations the error is: javax.el.ELException: Expression uses functions, but no FunctionMapper was provided...

This was recorded in the logs.

former_member185706
Participant
0 Kudos

I'd suggest to try "not" instead of "!" . For example :

<c:if test="${!r:tokenBasedSecurity(pageContext.servletContext)}">

should be

<c:if test="${not r:tokenBasedSecurity(pageContext.servletContext)}">

Former Member
0 Kudos

I'm not sure if "not" is part of the specification. "!" definetly is. Anyway, a space after "!" works fine. For example this works:

<c:if test="${!r:tokenBasedSecurity (pageContext.servletContext)}">

But no space should also be supported.

former_member185706
Participant
0 Kudos

This is excerp from the Expression Language Specification Version 2.1

1.14 ReservedWords

The following words are reserved for the language and must not be used as

identifiers.

and eq gt true instanceof

or ne le false empty

not lt ge null div mod

You're right that without space should be supproted...maybe in some next relaeases will be fixed...

I've just suggested workaround for you

Bets Regards

Bojidar

Answers (0)