The valid characters are defined in RFC 7230 and RFC 3986

We Are Going To Discuss About The valid characters are defined in RFC 7230 and RFC 3986. So lets Start this Java Article.

The valid characters are defined in RFC 7230 and RFC 3986

  1. The valid characters are defined in RFC 7230 and RFC 3986

    If you use an upper version of Tomcat 8.5 it throws this exception if the URL path contains '[' and ']'. For older versions, it works.

  2. The valid characters are defined in RFC 7230 and RFC 3986

    If you use an upper version of Tomcat 8.5 it throws this exception if the URL path contains '[' and ']'. For older versions, it works.

Solution 1

If you use an upper version of Tomcat 8.5 it throws this exception if the URL path contains ‘[‘ and ‘]’. For older versions, it works.

Original Author Dani Of This Content

Solution 2

The workaround would be adding below attributes to http connector port in tomcat server.xml file

relaxedPathChars="[]|" relaxedQueryChars="[]|{}^\`"<>"

Original Author Sreekanth Kategaru Of This Content

Solution 3

The error message says “Invalid character found in the request target”. This means the HTTP client sent a request for a resource that had an invalid characters in it. The server can not parse the request because the request did not adhere to the HTTP protocol specifications.

This is a client problem. Fix the client.

If it is a public server, maybe someone is trying to break in by sending malformed requests (it’s common).

Original Author Torben Of This Content

Solution 4

I encountered the same error when sending location of a file in a AJAX GET request.

Since the location had characters which are not recognized. I.e. “C:///” etc, the error was thrown.

The use of encodeURIComponent helped me fix the issue since it encodes the component.

When you pass the location make sure you add those inside “encodeURIComponent” method. In my case:

 $.ajax({
        type: "GET",
        url: 'removeFile?removeFilePath=' + encodeURIComponent("C:///YO/Ed/PO/")
        data: {},
        dataType: 'json',

Original Author Dulith De Costa Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment