1

I am using a Servlet and JSP to display a webpage. But whenever I use the Euro currency I get a question mark(?). When I print out in the lgs its fine but when it renders in the HTML it doesn't... Anyone know how to fix?

 Currency c  = Currency.getInstance("EUR");
 System.out.println(c.getSymbol());
 String minListPrice =c.getSymbol()+(int)sorteList.get(i).getTicketInfo().getMinListPrice();

enter image description here

user1163234
  • 2,407
  • 6
  • 35
  • 63
  • You must read this: https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/ – gsl Dec 10 '18 at 17:15

1 Answers1

2

You should use UTF-8 encoding to avoid this problem.

Check this answer to know how to do it.


On JSP:

<%@ page contentType="text/html; charset=UTF-8" %>

Server side:

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws ServletException
{
   request.setCharacterEncoding("UTF-8");
   chain.doFilter(request, response);
}
Maarti
  • 3,600
  • 4
  • 17
  • 34