preserve line breaks in applet parameters

  • Thread starter www.douglassdavis.com
  • Start date
W

www.douglassdavis.com

it seems every time i pass some text through an applet parameter, say:

....
<PARAM name="mytext" value='
This
is
a
test
'>
....


when i get the String, and print it out in the console window, it
never has the line breaks there. Is there any way I can preserve the
line breaks so that they are represented the same way they are in the
HTML?

If so, can some one explain exactly how?
 
T

Toby Inkster

www.douglassdavis.com said:
when i get the String, and print it out in the console window, it
never has the line breaks there. Is there any way I can preserve the
line breaks so that they are represented the same way they are in the
HTML?

Probably not -- or rather, not consistantly across different browsers. It
is the browser that parses the PARAM element, not the Java engine. The
browser will use its normal rules for parsing attribute values, which in
many browsers will treat any extent of (horizontal or vertical) whitespace
as being equivalent to a single space character.

Try something like:

<PARAM name="mytext" value='|This|is|a|test|'>

and then using a regular expression (or such) in Java to replace '|'
chracters with '\n'.

Followups set to the Java groups for someone to post some example regular
expressions. (I would, but I can't remember how/if they work in Java.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,433
Messages
2,571,683
Members
48,796
Latest member
Greg L.

Latest Threads

Top