0

I am having a string which contains some special characters. ie "MCDO'S ". here in the code i am replacing it with the ascii html values like this.

riDescription.replace("\"", "").replace("\\", "").replace("'", "'");

here ' is replaced by ' Now the result which i am getting in UI is like this.

the string is appearing with the html values

Akash
  • 816
  • 3
  • 13
  • 38
  • In action class, you can use, `HtmlUtil.escape` (for storing in DB) to replace these special characters with respective ASCII literals. While on UI `HtmlUtil.unescape` will do the trick. – Parkash Kumar Sep 29 '16 at 07:45
  • I believe you will get your answer here http://stackoverflow.com/questions/30620543/java-how-to-encode-single-quote-and-double-quote-into-html-entities – mhasan Sep 29 '16 at 07:52
  • @ParkashKumar i ve passed this string in HtmlUtil.escape and in jsp again i am trying to unescape it but no success. – Akash Sep 29 '16 at 07:52
  • Have you verified by printing both values? Do you observe any difference? – Parkash Kumar Sep 29 '16 at 07:58
  • @ParkashKumar in console only i am getting this 08:31:04,830 INFO [OpsController:382] MCDO'S NALS FLAG' – Akash Sep 29 '16 at 08:32

1 Answers1

0

Description.replace("\"", "").replace("'", "'");

Loki
  • 801
  • 5
  • 13