In the JSP page, return line feeds are stored in the table method
1. Enter a section of text in a textarea, with line breaks, insert newline characters into the database
Use the following methods:
public static string texttohtml (String sourcestr)
{
int strlen;
String restring= "", Destr = "";
strlen = Sourcestr.length ();
for (int i=0; i<strlen; i++)
{
Char Ch=sourcestr.charat (i);
Switch (CH)
{
Case ' < ':
Destr = "<";
Break
Case ' > ':
Destr = ">";
Break
Case '/':
Destr = """;
Break
Case ' & ':
Destr = "&";
Break
Case 13:
Destr = "<br>";
Break
Case 32:
Destr = " ";
Break
Default:
Destr = "" + ch;
Break
}
restring = restring + destr;
}
Return "" + restring;
}
2. Read from the database to retrieve the car line feed
If the JSP page read <br> can not wrap (at this time JSP read may be "<" escaped to < ">" escaped into > Cannot wrap at this time, you can do so in the Java method
The saved string contains <br> characters to be replaced with other words Furu: ReplaceAll ("<br>", "# (or other)");
In the JSP page with JS to replace the characters above replaced again into <BR>, the replacement value assigned to the JSP need to display the place can;
JS replacement such as: Var str=str.replace (//#/g, "<br>")
document.getElementById ("id"). value=str;