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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:09:28+00:00 2026-05-23T05:09:28+00:00

How can I display my list in a TestArea line after line with no

  • 0

How can I display my list in a TestArea line after line with no additional spaces. i.e:

this
that
the
other

Here is my attempt:

<div class="text">
    <label for="output_string">Output:</label> `
    <textarea rows="10" cols="20">
        <c:forEach var="x" items="${messagelist}">${x}</c:forEach>
    </textarea>
</div>
  • 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-05-23T05:09:29+00:00Added an answer on May 23, 2026 at 5:09 am

    Here’s a guess (which I’ll try out in just a sec in one of my own pages):

    <c:forEach var='x' items='${messagelist}'><c:out value='${x}\r\n'/></c:forEach>
    

    edit — no that doesn’t seem to work at all. However, what did work was for me to add a message catalog entry like this:

    linebreak={0}\r\n
    

    Then you can use <fmt:message key="linebreak"><fmt:param value="${x}"/></fmt:message> to produce the string terminated by line breaks.

    Note that JSP will put spaces before the first entry according to the indentation in your .jsp source file before the <c:forEach>, so you’ll have to line everything up at the left edge if you don’t want that.

    If I had to do this a lot, I’d write an EL add-on function of my own to echo back a string followed by CRLF.

    edit — If you want to write an EL add-on, you need two things:

    • The function itself, which should be a public static method of some class. I keep a class around called “ELFunctions” for most of mine. You can arrange them any way you want.
    • A “.tld” file, if you don’t already have one. It should end up in your webapp somewhere under “WEB-INF”. Mine goes in a subdirectory called “tld”, but you can put it anywhere.

    So you would write a little function like this, in some class:

    public static String linebreak(final String msg) {
        return msg + "\r\n";
    }
    

    Then your “.tld” file would look like this (assuming it’s the only thing you’ve got; if you have an existing “.tld” file just add the clause):

    <taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" version="2.0">
      <description>Your Favorite Description</description>
      <display-name>Make Something Up</display-name>
      <tlib-version>4.0</tlib-version>
      <short-name>whatever</short-name>
      <uri>http://yourdomain.com/tld/whatever</uri>
    
      <function>
        <description>
            Return a string augmented with trailing line break (CR - LF pair)
        </description>
        <name>linebreak</name>
        <function-class>your.package.name.YourClass</function-class>
        <function-signature>
            java.lang.String linebreak(java.lang.String)
        </function-signature>
      </function>
    

    (Boy, XML is so annoying.) Now somewhere you probably already have a little file that pulls in taglibs for your pages (for <c:...> tags at least). In there, or at the top of any page, add a line like this:

      <%@ taglib prefix="whatever" uri='http://yourdomain.com/tld/tango' %>
    

    I think that the JSP runtime searches for “.tld” files by looking through the WEB-INF subtree, and in .jar files in WEB-INF/lib, matching by that “uri” string. Anyway, once you’ve done that, in your JSP file you can say:

      <c:forEach var='x' items='${messagelist}'>${whatever:linebreak(x)}</c:forEach>
    

    and it’ll invoke your function.

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

Sidebar

Related Questions

I'm making a custom adapter so that I can display a list of items
I have a search form that can display a list of persons matching the
I have simple application, that shows list of many items, where user can display
How can i display a list of images stored in an array as list
Can someone help me find the error when I tried to display the list
I'm writing an application that displays a list of objects which the user can
I can display a simple Visual Basic inputbox from a PowerShell script like this:
Possible Duplicate: Is there a tool that can display a SVN repository visually (
Examotion has a player that can display the image for svg files as a
I'm just starting with Android and can't find how to display a list in

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.