Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7884275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:45:19+00:00 2026-06-03T04:45:19+00:00

I have an ArrayList of custom beans. I’d like to use the jstl join

  • 0

I have an ArrayList of custom beans. I’d like to use the jstl join function with an ArrayList by calling the toArray method of the ArrayList and then overriding toString on the objects it contains.

It’s been said that there is nothing really stopping me from extending classes to include a “get” for methods/properties that I would like to expose to JSP.

So, for this example:

class MyArrayList extends ArrayList
{
  public Object[] getToArray()
  {
     return this.toArray();
  }
}

Good idea?

I’ve been creating classes like this with re-usability in mind which has me wondering: Is there a library in existence that simply extends a lot of core Java classes by aliasing useful methods to have a “get” version so they can be used in JSP?

Of course, this may be another case of me not quite grasping some fundamental concepts with regard to JSP but I see it as pure inconvenience that only bean type classes with the “get” style method names can be used in a JSP page. If so, please feel free to tell me why a library like this is a bad idea. Basically, if a library like I describe doesn’t exist, why not?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:45:21+00:00Added an answer on June 3, 2026 at 4:45 am

    As to your concrete functional requirement, you could create a custom EL join() function which takes a List or Collection.

    E.g.

    package com.example;
    
    import java.util.Collection;
    
    public final class Functions {
    
         private Functions() {}
    
         public static <E> String join(Collection<E> collection, String separator) {
             StringBuilder builder = new StringBuilder();
    
             for (E element : collection) {
                 if (builder.length() > 0) {
                     builder.append(separator);
                 }
    
                 builder.append(element);
             }
    
             return builder.toString();
         }
    
    }
    

    Which you register as follows in a /WEB-INF/functions.tld file:

    <?xml version="1.0" encoding="UTF-8" ?>
    <taglib 
        xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
        version="2.1">
    
        <tlib-version>1.0</tlib-version>
        <short-name>Custom Functions</short-name>
        <uri>http://example.com/functions</uri>
    
        <function>
            <name>join</name>
            <function-class>com.example.Functions</function-class>
            <function-signature>java.lang.String join(java.util.Collection, java.lang.String)</function-signature>
        </function>
    </taglib>
    

    Which can finally can be used as

    <%@taglib prefix="f" uri="http://example.com/functions" %>
    
    ${f:join(bean.list, ', ')}
    

    Or if you happen to have Apache Commons Lang already in the classpath, just delegate to it instead.

        <function>
            <name>join</name>
            <function-class>org.apache.commons.lang.StringUtils</function-class>
            <function-signature>java.lang.String join(java.util.Collection, java.lang.String)</function-signature>
        </function>
    

    As to your initial question, I would rather not add custom public methods to an custom implementation of an already existing interface and rely on that custom implementation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ArrayList of objects of my custom class. I would like to
My use case is as follows -- I have a list(ArrayList) of objects, custom
I have overridden the ApplySortCore method for a custom BindingList like so: public void
I have an ArrayList of custom, simple Serializable objects I would like to cache
I have an ArrayList that I want to use to hold RaceCar objects that
I have an ArrayList of items that are linked to a custom Adapter. The
I have a simple program where I would like to save an arraylist to
I have an h:dataTable with data generated from an ArrayList with custom object Result.
I have a custom listView. The main layout xml is something like this: <?xml
I have created an ArrayList (Java) of my custom class objects with a size

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.