Results 1 to 6 of 6

Thread: JSTL endswith bug

  1. #1
    Join Date
    Jun 2006
    Location
    Kansas City
    Posts
    95

    Thumbs down 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. #2
    Join Date
    Jun 2006
    Location
    Kansas City
    Posts
    95

    Lightbulb

    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)) != '.'}"

  3. #3
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    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.
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


  4. #4
    Join Date
    Jun 2006
    Location
    Kansas City
    Posts
    95

    Default

    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 at 02:16 PM.

  5. #5
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    Quote 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

  6. #6
    Join Date
    Jan 2011
    Location
    Kirovohrad, Ukraine
    Posts
    59

    Default 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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •