...

View Full Version : what is new line in <textarea>



BubikolRamios
02-24-2010, 06:38 PM
1.I type multiline (hiting enter) into html textarea.
2. save as it is, to MYSQL, there it becomes one single line
3. pick it up in java from database, there it looks ok, multiline, in debuger
4. send back to client , again one single line !?

tryed, before sending to client:


s = s.replaceAll("$","</BR>");

but looks it is realy one single line coz </BR> appears only at the end of s.

How to handle that ?

BubikolRamios
02-24-2010, 07:01 PM
//works
s=s.replace("\n","<BR>");
//does not
s=s.replace(System.getProperty("line.separator"),"<BR>");

_Aerospace_Eng_
02-24-2010, 07:11 PM
Are you using java or javascript?

BubikolRamios
02-24-2010, 07:53 PM
java of course,


s=s.replace("\n","<BR>");

works on linux and win, so this is database dependant.

_Aerospace_Eng_
02-25-2010, 03:23 PM
It looks like java has an nl2br method. You may want to look into it.

http://njet.org/api/anvil/util/Conversions.html

I couldn't find much documentation on the nl2br method. Also have you tried this?

s=s.replaceAll(System.getProperty("line.separator"),"<BR>");



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum