0

I have a bean which has String property, which stores copyright symbol

private String copyright = "my company © 2016 All rights reserved";

public String getCopyright() {
     return this.copyright;
}

The problem, that jspx page don't display copyrigh symbol. It jus displays text like this:

my company © 2016 All rights reserved

How can I return text which contains copyright symbol in jsp?


This is how I get that bean property in jsp page

In this case copyright symbol is not displayed

<TD align="center" style=" font-size: 10pt; font-family: Arial; ">
     #{copyrightBean.copyrights}  
</TD>

Now copyright symbol is dispalyed, but it didn;t come from bean:

<TD align="center" style=" font-size: 10pt; font-family: Arial; ">
     &#169;
</TD>
Benas
  • 2,106
  • 2
  • 39
  • 66

2 Answers2

1

The & in the string is escaped when printed in the JSP page (the HTML will contain a string "my company &amp;#169; 2016...").

Therefore the string should not escape the copyright symbol:

private String copyright = "my company © 2016 All rights reserved";
wero
  • 32,544
  • 3
  • 59
  • 84
0

You must be HTML escaping your call to the bean. If you view the source of your HTML, you'll see

 &amp;#169;

There are two solutions:

  • Use the UTF-8 character instead (simplest): ©
  • Don't auto-escape your template content, the exact way will depend on the templating engine you are using
Ruan Mendes
  • 90,375
  • 31
  • 153
  • 217