I have a JSP page with a textarea HTML component. When a user presses enter and goes to next line while typing in textarea,and when he clicks save button, it saves the data from the text area to the database. But when I load the content of the database, the line breaks are gone. Means:
HELLO
WORLD
is displaying like
HELLO WORLD
I tried the method given here How do I replace all line breaks in a string with <br /> tags? but its not working. I also tried this one How to save user-entered line breaks from a TextArea to a database? but I am not using PHP and also the solution given here for another languages to replace "\n" with "<br />" also not working. Please anyone have any idea how to do that?
I tried this code:
String a=req.getParameter("topicdes").toString();
a.replaceAll("\n","<br />");