Tomcat server is responding with 400 bad request for this URL

9.1k Views Asked by At

I've deployed a static web application using Apache Tomcat 8.5.8

When I call the normal URL, it works fine. http://localhost/example/index.html

But when I call the following URL, it gives me 400 bad request error. http://localhost/example/index.html?host_info=Outlook|Web

I know it's because the URL has the special character (|). But I couldn't configure the Tomcat, because I am pretty new with the Tomcat configuration.

And I can't change the URL, because it's not something I generate. It is from the other component.

So I really need to configure the Tomcat server so that it can accept the url.

Can anyone help me in this?

2

There are 2 best solutions below

2
On BEST ANSWER

Try to use the tomcat 8.0.* instead of 8.5 I also faced the same issue before, and I had to downgrade the tomcat to 8.0.28

1
On

This behavior was introduced in Tomcat 7.0.76, 8.0.42 and 8.5.12, to conform RFC 7231.

This enforced check can be revert using the property requestTargetAllow in catalina.properties to allow forbiden characters:

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