0

I have some text, which I want to display using java (on jsp page) and using javacript. but when I use \ then text in javascript is shown correctly but java shows it with one more back slash. the text is the same, is there some way how I can have them displayed the same way?

Max
  • 12,622
  • 16
  • 73
  • 101
bearbearbear
  • 95
  • 1
  • 2
  • 11

1 Answers1

0

This is what is called an "escape sequence" for a variety of security reasons many characters do not print when written directly in a string literal.

Common c style escape sequences are prefixed with '\' (backslash character) followed by the character to escape

'\\' is the character sequence you're looking for to print a single '\' character.

wiki page

see older stackoverflow comment.

 - \t Insert a tab in the text at this point.
 - \b Insert a backspace in the text at this point.
 - \n Insert a newline in the text at this point.
 - \r Insert a carriage return in the text at this point.
 - \f Insert a formfeed in the text at this point.
 - \' Insert a single quote character in the text at this point.
 - \" Insert a double quote character in the text at this point.
 - \\ Insert a backslash character in the text at this point.
Community
  • 1
  • 1
t3dodson
  • 3,949
  • 2
  • 29
  • 40