I have this problem:
I have an HTML textarea which is filled by the user. (And he can press The enter button to go on a new line).
Then I take The value of The textarea using the command:
document.getElementById("textareaCommento")
And I pass The value to the servlet using an XmlHttpRequest.
In The servlet I save this value in a database.
Since this point I have no problems…
Then, in another part I want to get The values from The database. Using a servlet I make this query
Select * from comments
And I transform the results in json. Here I have The problem… The newline character makes my JSON string invalid. For example:
"Comment":"hello
Word"
How can I do?
Thanks in advance!
You have to replace the
\ncharacter from database to something like<br/>For the replace see replace \n and \r\n with <br /> in java