UTF-8 IN JSP does not work

0

I have been trying to get my form to save the ñ character, however whenever I debug this character is replaced ... what is it due to?

I have tried this way:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="fecha.jsp" %>
<!DOCTYPE html>
<html lang="es">
<head>
    <title>Agregar Usuario</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><!--opcion 1-->
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/><!--opcion 2-->

Neither of the two options has worked for me whenever I enter the debug, where I make the request of the view other characters appear replacing the ñ

NOTE

My problem is not when viewing on the page, it is in the form when you sent the data to be saved.

EDITION

The server I am using is glassfish, I tried the configuration to the server, which by default is UTF-8 and my problem continues.

    
asked by Andres Felipe Diaz 16.05.2017 в 16:56
source

2 answers

0

My problem was solved by removing this tag from the page .jsp

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

Apparently this generated that I converted the accents and kept poorly in the BD.

I hope someone serves you ... Greetings!

    
answered by 18.05.2017 / 16:54
source
1

Apart from the .jsp , which will be used to render it correctly in the view. It would be necessary that the coding of tomcat be in UTF-8 as well.

Inside the folder conf of tomcat there should be a file server.xml look at the labels Connector have the attribute URIEncoding="UTF-8"

It should look something like this:

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" 
               URIEncoding="UTF-8"/>

Besides, the encoding of the editor you are using should also be encoded to UTF-8 to avoid unusual characters in it.

    
answered by 16.05.2017 в 17:13