Discussions

General J2EE: retrieving String value using scriptlet within js code

  1. retrieving String value using scriptlet within js code (1 messages)

    Hello- A js error "unterminated string literal" occurs when writing the following lines alert('<%=x%>'); while it doesn't when using a pure js code like the following var x = "x\ny"; alert(x); can anybody help? thank you

    Threaded Messages (1)

  2. Escape your newline[ Go to top ]

    If you view source in your browser, you will likely see that the java newline gets rendered into the html, causing invalid javascript. If you escape the backslash on your newline, it will likely work. alert('<%=x%>');