I have a form that takes a list of values, each value is indicated on a separate line textArea. In my servlet, I sign the line that I get from this textArea, based on the new characters of the string "\ r \ n", for example:
String[] partNumberList = originalPartNumberString.split("\r\n");
This is working fine. I get an array of values ββas expected. I believe this is due to the fact that the browser handles the standardization of the method of sending new lines to the server, regardless of which OS / browser submits the form data ( see this post ), I tested it in IE, Firefox, Chrome ... all seems to work fine with this, and I feel pretty confident about it.
After receiving the server-side values, I then use these values ββfor some search queries, etc., then I return them back to textArea for a response. To do this, I write it the same way I get it ... I just create a new line and separate each value with "\ r \ n". Then I set the value of textArea to this line.
StringBuffer invalidReturnPartList = new StringBuffer("");
for (int i = 0; i < requestedPartList.length; i++)
{
invalidReturnPartList.append(requestedPartList[i]);
invalidReturnPartList.append("\r\n");
}
return invalidReturnPartList.toString();
This also checks OK for me in all browsers I tried. However, I'm just nervous about whether I cover all of my databases here ... if someone is running on a Mac, will "\ r \ n" translate correctly into my browser? What about Linux? I would have thought that everything would be handled in a browser, but I'm just not sure here ... so my question is: does this look like you, or did I miss something?