Surround your output (<bean:write...) with <pre> and </pre> which tells the
browser to render it as preformatted text , and will respect spaces,
newlines, tabs etc...
This is also very useful if you need to show an exception stack trace in the
browser.
Note that within a <PRE> block, not all html elements can be used (shouldnt
be an issue in this particular case though as you just want to display that
fields contents).

-----Original Message-----
From: Walter Fu [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 11, 2002 07:16
To: '[EMAIL PROTECTED]'
Subject: <bean:write> data containing html tag?


This might be a problem that people have already seen and solved:
<html:textarea> is used for the user to enter data.
1. A single line of data may be so long that textarea wraps it around
automatically. So it looks to the user as one paragraph.
2. There can be many new lines ( \n ) in the data when the user hits the
Enter key.

Once the data is captured as a String property, it can be shown to the user
on a subsequent page correctly in a textarea.

If on the subsequent page I wish to use not a textarea (not even with the
readonly attribute) but something like <bean:write> to echo the data, how do
I "preserve" the \n in 2?

The browser would auto-wrap the text correctly. So that satisfies 1. The \n
of course is treated by the browser as a single space. So the original
paragraphs in 2 are "lost".

One possibility is to replace \n with <br/> in the data. When I did that,
the <br/> came out as &lt;br/&gt; This is not what I wanted.

Any suggestions?

Thanks,

Walter


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to