Results 1 to 6 of 6

Thread: JSTL and string concatenation possible?

  1. #1
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default JSTL and string concatenation possible?

    I have ${stub} = 2@3# and ${levels} = [1, 2, 3, 4]

    I would like to do something like
    Code:
    <c&#58;forEach var="level" items="$&#123;levels&#125;">
      <c&#58;out value="$&#123;stub&#125;$&#123;level&#125;"/>
    </c&#58;forEach>
    resulting in
    • 2@3#1
      2@3#2
      2@3#3
      2@3#4


    I've tried every(?) possible combination. Is String concat without any blankspace possible in JSTL?
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    did you try
    Code:
    <c&#58;forEach var="level" items="$&#123;levels&#125;"> 
      <c&#58;out value="$&#123;stub&#125;"/><c&#58;out value="$&#123;level&#125;"/> 
    </c&#58;forEach>
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default Hi

    Problem is I have to assign it to a new variable:

    Code:
    <c&#58;set var="stubplus" value="<c&#58;out value="$&#123;stub&#125;"/><c&#58;out value="$&#123;level&#125;"/>" />
    Chokes on "unterminated tag" unforunately....
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  4. #4
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    Then try this
    Code:
    <c&#58;forEach var="level" items="$&#123;levels&#125;"> 
      <c&#58;set var="stubplus" value="$&#123;stub&#125;$&#123;level&#125;" /> 
      <c&#58;out value="$&#123;stubplus&#125;"/>
    </c&#58;forEach>
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  5. #5
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    Mark Kolb wrote a good article about JSTL on developerWorks.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  6. #6
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default

    Thanks! Appreciate your answers.
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

Similar Threads

  1. Pageable data list with Hibernate
    By robmorgan in forum Data
    Replies: 23
    Last Post: Jul 24th, 2006, 06:12 PM
  2. Replies: 6
    Last Post: Apr 4th, 2005, 04:37 PM

Posting Permissions

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