0

\n is within a string...

String str = request.getParameter("textfieldvalue");

I want to display the value of str to other pages..using this link below.

window.open("page.jsp?param=<%=str%>")

....the problem is that the window is not opening due the str has \n.


How to read \n in a string?

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by toughlittleone
0

\n is within a string...

String str = request.getParameter("textfieldvalue");

I want to display the value of str to other pages..using this link below.

window.open("page.jsp?param=<%=str%>")

....the problem is that the window is not opening due the str has \n.


How to read \n in a string?

I don't know if it will work, but try to replace the char: '\n' which is in the String with this: <br>

0

You can apply trim() method on the given string to trim leading and trailing whitespaces. Also since str forms a part of the URL, make sure you URL encode the string so that special characters are taken care of [e.g. &, ; etc.].

One question though: How did a newline character manage to find its way into a text field?

0

can't believe I didn't think of this, great solution!

I was creating an XML style string, and I did this just like you suggested:

"&lt/soapenv:Header&gt" + "<br></br>";

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.