Incorrect character display in html/jsp page

Asked

Viewed 243 times

1

I was designing a website for academic purposes, but I came across a visualisation error. My html/jsp pages are not displaying the accented text correctly when retrieving from the database.
All are charset UTF-8 in the meta tag and lang en in the html tag. The database I use is Mysql 5.7. Both to insert and to display in the mysql shell, the accents are displayed correctly. The problem occurs when I insert or edit a record via html/jsp page, then, whether displaying on the page or shell, the characters get bugged.

Example of a line:

Alessandro are welcome No email 000012341234 17/07/1990

Within a form of a . jsp, I change a contact by sending the parameters to a Servletcontroller that sends to a class that executes the logic.

public class AlteraContatoLogic implements Logica {
@Override
public Pagina run(HttpServletRequest request, HttpServletResponse response) throws Exception {
    // buscando os parâmetros no request
    long id = Long.parseLong(request.getParameter("id"));
    String nome = request.getParameter("nome");
    //String endereco = new String(request.getParameter("endereco").getBytes("UTF-8"));
    String endereco = request.getParameter("endereco");
    String email = request.getParameter("email");
    String telefone = request.getParameter("telefone");
    String dataEmTexto = request.getParameter("dataNascimento");
    Calendar dataNascimento = null;

    // fazendo a conversão da data
    try {
        Date date = sdf_dmy.parse(dataEmTexto);
        dataNascimento = Calendar.getInstance();
        dataNascimento.setTime(date);
    } catch (ParseException e) {
        throw new ServletException(e);
    }

    // monta um objeto contato
    Contato contato = new Contato();
    contato.setNome(nome);
    contato.setEndereco(endereco);
    contato.setEmail(email);
    contato.setDataNascimento(dataNascimento);
    contato.setTelefone(telefone);
    contato.setId(id);

    // altera no bd
    new ContatoDao().set(contato);

    return new Redirecionador(request, response, "./");
}

}

Does anyone know what it can be and how to solve it?
Grateful from now on.

  • Which table paste your bank ? most of the time just insert the native method utf8_encode() into the various which may have accentuation.

  • charset=utf8 and collate=utf8_general_ci

  • Try to change to Latin, I use so at least, and rarely some coding problem: charset = Latin1 and collate = latin1_general_cs . Cs is to differentiate between M and m.

  • Both with Cs or ci as collate, still does not change in the exhibition. It remains strange.

  • Puts an example line question that brings the error and the code snippet

  • Already tested in another browser?

  • I did it! I migrated to postgresql with the database encoding=utf8, collate=pt_BR.UTF-8 and Ctype=pt_BR.UTF-8 and charset the pages using iso-8859-1.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.