Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986. TOMCAT 7.0.78

1

Through javascript I have created a function to put information in a text box. I have written the special characters and I want to introduce the ñ / Ñ and the accents. By filling in that text box and giving the save button gives the error Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986, in my tomcat with version 7.0.78. I have looked at many sites, and commented something about changing catalina.properties and server.xml , I have modified them and still giving the same error, in the bbdd that is from Oracle I have also modified the encoding to UTF-8 so that it admits all the characters but the Tomcat does not take them. Let's see if someone can give me a hand because I do not know what else to look for. In the file of catalina.properties I added this line

tomcat.util.http.parser.HttpParser.requestTargetAllow=|{}

and in the server.xml I added

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

Thanks in advance. Greetings !!

The servlets that do the operation use the doPost method, I do not know if you mean that. I've been keeping an eye on those methods, is it valid for any browser? Since the application at the moment is only used in IE. And another question, if I already have my code made to call the function that handles the characters that can be entered, these functions where should I implement them?

function check() {
    // Patron de entrada
    patron1 = /[^a-zA-Z 0-9.]+/g,' '; // mayúsculas, minúsculas, números y espacio
    patron2 = /^[a-zA-ZáéíóúÁÉÍÓÚ]*$/; // acentos 
    patron = patron1 + patron2;
    tecla_final = String.fromCharCode(tecla);
    return patron.test(tecla_final);
}

This is the function to enter the characters that are indicated.

    
asked by Marta M. 06.08.2018 в 12:26
source

1 answer

1

From what I've been reading this error occurs when the URL contains invalid characters, not the body of the request.

The only thing that occurs to me is that you are doing a GET instead of a POST and you are creating a URL as http://algun_sitio/blah?parametro="años" .

If I am right, you must escape the invalid characters using the javascript functions encodeURI or encodeURIComponent

    
answered by 06.08.2018 в 13:56