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 8631591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:14:23+00:00 2026-06-12T09:14:23+00:00

I wanted to split a given string using jstl 1.2 eg: Bean thesis.url contains

  • 0

I wanted to split a given string using jstl 1.2
eg:

Bean thesis.url contains "http:website1.com : http:website2.com"
which needs to be splited into
http:website1.com
http:website2.com

<c:set var="url">
  <c:out value="${thesis.url}" />
</c:set>  

<c:set var="offUrls" value="${fn:split(url,' : ')}" />
<c:forEach items="${offUrls}" var="link">
    <a href=" <c:out value='${link}' />" target="_blank">
        <c:out value="${link}" />
    </a>
</c:forEach>

But the output is not want I wanted which is
http
website1.com
http
website2.com

I tried another way, and its dint work either.

<c:set var="_split" value= " : "/>
<c:set var="offUrls" value="${fn:split(url,_split)}" />

  • 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-12T09:14:24+00:00Added an answer on June 12, 2026 at 9:14 am

    fn:split will split your string on any of the delimiter characters, so in your case both space and :. The solution is to do a fn:replace first:

    <c:set var="urls" value="http://website1.com : http://website2.com"/>
    <c:set var="urls" value="${fn:replace(thesis.url, ' : ', '|')}"/>
    

    Make sure to replace the separator with a character that is not present in your string, or else you will run into the same problem. Now you can use fn:split(urls, '|'), but it would be easier to use <c:forTokens/>:

    <c:forTokens items="${urls}" delims="|" var="url">
      <a href="${url}">${url}</a>
    </c:forTokens>
    

    A better solution would be to simply do the work at the back end of your application and pass a list of strings to the front end.

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

Sidebar

Related Questions

How can I split a String by Unicode range in Ruby. I wanted to
I wanted to split a string Input : ABCDEFGHI Output : ABC, DEF, GHI
It seems to have modified the original string that I wanted to split specifying
Okay, so I'm using perl to read in a file that contains some general
I want to convert my single file program - which contains the data (
I am trying to tidy up my configuration file, and I wanted to split
I'm using the followin RegEx which I found in this similar question : /[^\s"]+|"[^"]*"/g
I wanted to do something like this: list($hour, $minute) = split(/:/, $departure_time); however it
I've always wanted a bit more functionality in STL's string. Since subclassing STL types
I have been trying to split a string by double newlines ( \n\n ).

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.