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

  • Home
  • SEARCH
  • 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 8931605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:09:01+00:00 2026-06-15T09:09:01+00:00

I have a requirement to concatenate a list of Strings using Java EL .

  • 0

I have a requirement to concatenate a list of Strings using Java EL. Please note that this is not in a JSP/Web context, but in a standalone Java client (using juel-2.2.4.jar).
The expression is of the form:

${for(int i=1; i<Employees.length; i++){Employee[i].Name + "--" }}

I already have a custom ELResolver which understands Employee objects.
The output I am expecting is a String with the names of all employees with a separator in between.

Is this even possible in a standalone Java EL application?

  • 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-15T09:09:02+00:00Added an answer on June 15, 2026 at 9:09 am

    You probably have to make a helper function, afaik, there is no way java can handle this with an expression out of the box.

    ${Employee.joinEmployeesByName(Employees, "--")}
    

    Code in the Employee class:

    public static String joinEmployeesByName( Employee[] arr, String separator ) {
        //implement
    }
    

    Here’s dynamic example using reflection:

    public static String getFieldByName(Employee obj, String fieldName) {
        String ret = null;
        Class<?> c = obj.getClass();
        try {
            Field field = c.getDeclaredField(fieldName);
            ret = field.get(obj).toString();
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return ret;
    }
    
    public static String joinEmployeesByField(Employee[] arr, String fieldName, String separator) {
        if(arr.length < 1) {
            return "";
        }
        StringBuilder ret = new StringBuilder();
        ret.append(getFieldByName(arr[0], fieldName));
        for( int i = 1; i < arr.length; ++i ) {
            ret.append( separator );
            ret.append( getFieldByName( arr[i], fieldName) );
        }
        return ret.toString();
    }
    

    Usage would be:

    ${Employee.joinEmployeesByField(Employees, "Name", "--")}
    ${Employee.joinEmployeesByField(Employees, "Designation", "--")}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have requirement to import Excel file in MySQL database using Java. I Googled
Hi I have requirement to create ,compile and load java classes run time. Using
I have this requirement to concatenate data from DNR2 (Parent) Message Data into the
I have requirement to disable copy/paste/cut operations on a textbox. For this purpose I
I have requirement of specifying web part connections in onet.xml. So when site is
I have requirement to get Facebook friends list with their images. How can I
Hi i have requirement to process large number of files via multithreading in java.
In our project we have requirement that, after receiving sms message from third party
For my ipad application i have requirement like this For each row in root
I have a requirement to concatenate values in different rows of my query based

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.