Issue
I'm trying to convert below message to represent in the text Area which i got from the The JAVA Rest API call (Thirdpaty)and the message is this
String x = "-----BEGIN PGP MESSAGE-----\nVersion: BCPG v1.58\n\nhIwDmCS94uDDx9kBA/4jkqEOWjbe03C1Dgd2A9eDBdk6cYczsOu6Typm0kjT15uQ\nT+Qc4Koz/yIq4gQpwccxRQ9NGl3Bi1cmPYvwxHIe+4bmqd31Izdkaj1VJCEVqZl2\nrLZvogFOo1oHUmdL2uIdUQJGJgslEOh91wp7CfxGhlxKSg0PvY3gyyWyofUwx9JU\nAUu+NY6YYrfd2l95C7EmMJXUDPysCitl/TGy04DbMuMNAyjZPPfkXqvjcG4A10nk\nPujs6RjnRYyCk+3ZJxvkhsjvGXKIQi7gTgWz7AV8vkBhSM2M\n\u003dRtkb\n-----END PGP MESSAGE-----\n"
When the message displays in the HTML text Area after applying regex patterns
x.replaceAll("(\r\n|\n)", "<br />");
x.replaceAll("(\r\n|\n)", "<br />");
<textarea rows="10" cols="50" id="test" name="test"><%=pKey%> </textarea>
still appearing like this
The Expected Output I'm not getting is this
Solution
Use this, x=x.replace("\\n", "<br />");
it will work
PrintWriter pw=res.getWriter();
pw.println("<textarea name='suggest_list' rows='10' id='word_suggest'>");
pw.println(x);
pw.println("</textarea>");
pw.println("</body></html>");
Output
Answered By - Vishnu T S