Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with formatted \n output from JSP to javascript

Status
Not open for further replies.

SilverStray

Programmer
Oct 25, 2001
47
AU
Hi,

I have a message string which I wanted to display as a message in the javascript. The message should be displayed as something like:

"Error in allocation.
Pls. contact support."

The following is the code that passes this message to the intended javascript:

String msg="Error in allocation. \\n Pls. contact support."
stringURL = "ResultPage.jsp?message=" + msg;

It works fine in a server using java 1.4.2_04. But in a server using java 1.4.2_06, the message is displayed as follows:

"Error in allocation. /n Pls. contact support."

Is there an issue for formatting with different java versions??

Pls. help enlighten me.

thanks in advance!
 
I tried this using JDK 1.3 and Tomcat and it worked fine.

I also tried it with JDK 1.5 and it worked.

Not much help, I'm afraid, except to suggest that the JDK difference may not be the cause...
 
You should not double-escape the backslash :

Change :
String msg="Error in allocation. \\n Pls. contact support."

to :
String msg="Error in allocation. \n Pls. contact support."

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top