Announcement Announcement Module
Collapse
No announcement yet.
JSTL endswith bug Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JSTL endswith bug

    I've stumbled upon a documented bug in the JSTL functions endswith function.

    http://www.mail-archive.com/taglibs-.../msg03618.html

    ${fn:endsWith('paymentMethod.billingAddress.', '.')}

    returns false. From discussions I have seen it occurs when the search string occurs more than once. I gather that it was coded with indexOf() and if that returns something other than the last index, it returns false.

    One of the posters mentions a workaround from Jochen Metzinger, which says cryptically, "Use String#endsWith".

    Does anyone know what this means? Does this refer to another taglib?

  • #2
    I've since coded a workaround that I'll share with everyone:

    ${fn:endsWith(string, '.')}

    ... can be replaced with...

    ${fn:substring(string, fn:length(string)-1, fn:length(string)) != '.'}"

    Comment


    • #3
      I suppose you could write your own custom tag function relying on String.endsWith instead?

      On the soapbox for a moment, it's kind of disappointing that the jakarta-taglibs project has essentially gone defunct. There are still plenty of people who use them, and it's too bad that bugs like this go unfixed.

      Comment


      • #4
        Some of the posts mention a patch, but I can't find any more info on it. I'm using

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

        ... which is the most current release as far as I can tell, so if such a patch was made, it wasn't applied or doesn't work.

        If there are more actively maintained alternatives, I'd like to know about them.
        Last edited by kcflyer; Jun 4th, 2007, 03:16 PM.

        Comment


        • #5
          Originally posted by kcflyer View Post
          <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

          ... which is the most current release as far as I can tell, so if such a patch was made, it wasn't applied or doesn't work.
          As far as I can tell this namespace uri only points to a specific JSTL version (1.1), but not to any specific implementation. So it matters which implementation you are using.

          I'm using JSTL 1.1 from the Apache Jakarta Taglibs project in implementation version 1.1.2.

          Jörg

          Comment


          • #6
            Any other solutions except substring work-around?

            I'm sorry for necro-posting but this problem bothers me and I wouldn't like to create a new post.

            This bug seems to be resolved 4 years ago! How come all maven repositories still contain it?

            Maybe I'm missing something obvious? As Jörg Heinicke mentioned there might be other implementations of JSTL. Can anybody suggest some?

            Comment

            Working...
            X