The Artima Developer Community
Sponsored Link

Java Answers Forum
Escape \n in a string in jsp

1 reply on 1 page. Most recent reply: Dec 12, 2006 2:32 PM by Solomon Kwon

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
surekha mitnala

Posts: 6
Nickname: pulipaka
Registered: Oct, 2006

Escape \n in a string in jsp Posted: Dec 12, 2006 5:51 AM
Reply to this message Reply
Advertisement
Hi All,

I have a code in this way:
javascript:

var msg = "";
msg = msg+"<%=errorMsg%>";
var error1 = msg.replace(/\r|\n|\r\n/g,"");
alert(error1);

errorMsg consists of the following string which has \n or\r, I am not sure.
"Node Controller 1 : AddToCluster; nested exception is:
java.net.ConnectException: Connection timed out: connect"

The need to get an alert box with this message. But the error is "Unterminated String Constant". I am not able to pop the alert box.

Please help me how can I get rid of this.... :-((

Regards,
Surekha Pulipaka


Solomon Kwon

Posts: 1
Nickname: techjunky
Registered: Dec, 2006

Re: Escape \n in a string in jsp Posted: Dec 12, 2006 2:32 PM
Reply to this message Reply
Making it static will indeed ensure you have only a single object in memory.

Do a Google on "Singleton", a widely used design pattern that addresses exactly what you're asking.

Cheers,
TJ

Flat View: This topic has 1 reply on 1 page
Topic: Escape \n in a string in jsp Previous Topic   Next Topic Topic: why I get en exception?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use