Displaying text in JSP

Hi,

I noticed a problem in displaying stored text. I am using <textarea> to get the text, and store it in a MySQL db as a Blob.

When I try to display as a <textarea>, using getString() it works fine!

But, I don't like the look as it is readonly information.

If I use just a <%= getString() %>, then I get all the information, BUT it ignores all the CR/line feeds...

Any suggestions on how to fix this?

Thanks,

Anil

[483 byte] By [anilnkumara] at [2007-10-3 0:50:44]
# 1
A few possibilities here:1) replace newlines with breaks2) use the <pre> tag to keep the formatting3) use a textarea, but make that textarea readonly<textarea readonly><%=getString()%></textarea>
gimbal2a at 2007-7-14 17:45:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanks for that quick response, gimbal2...

Your solution #3 works fine, but I don't like the look. Besides I want to display all the information completely, not with a scroll bar...

I can't use the #1 solution, as I will need to figure out the end of line.....

I am not sure about the #2 <pre>... Can you show me line on how to use it?

By the way, WHAT HAPPENED TO FORMATING HERE? This is exactly my problem, except I don't see the

in my display...

anilnkumara at 2007-7-14 17:45:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

By default, HTML ignores all white space, turning it into a single space.

A <pre> tag overrides that, so that it will print all of your spaces/carriage returns in a <pre> tag through to the browser.

ie - you're telling the browser 'Don't muck with my formatting - this is how I want it'.

<pre><%= displayTheInfo() %></pre>

And it seems that they are 'upgrading' the forums again. Any time they try this it breaks. I'm not sure WTF is happening right now, but I'm not gonna be answering many questions if I can't read them ;-)

evnafetsa at 2007-7-14 17:45:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
THANKS, evnafets!!!It worked like charm, especially since I don't have to do the formating myself....:;-)
anilnkumara at 2007-7-14 17:45:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...