Input to textarea :(These 3 lines)
<textarea id="preM" rows="3" cols="10" style="resize: none; width:100%;">
</textarea><br/>
This is example of textarea
This is new Line
Hello All
In JSP page I am retrieving the value of Text Area
String variableString = request.getParameter("preM");
System.out.println(variableString);
Output is coming as:
This is example of textarea This is new Line Hello All
Expected output:
This is example of textarea
This is new Line
Hello All
I have already tried
StringBuffer preM = new StringBuffer(request.getParameter("preM"));
int loc = (new String(preM)).indexOf('\n');
while(loc > 0){
text.replace(loc, loc+1, "<BR>");
loc = (new String(preM)).indexOf('\n');
}
out.println(preM);
But getting loc=-1
.