1

No change made at the code, simply I installed an application (struts2) developed using tomcat 8.0.23 on new environment that uses 8.0.50. The problem is in sending a short json from client (javascript) to server (java). In the former version I was using an url like this:

http://127.0.0.1:10080/dlq/updprat?jsonparams={%22datavz%22:%2209/04/2018%2014:18:12%22,%22descavz%22:%22foo%20foo%22,%22idprat%22:32,%22codprat%22:%22123456%22,...etc...,costs%22:[]}&pratAffidateSearchType=a

and all was running fine.
Now the system returns me the following error:

org.apache.coyote.http11.AbstractHttp11Processor.process Error parsing HTTP request header java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

I localized the error in the braces: those aren't accepted anymore!
how can I remedy the problem? The app don't use ajax framework (like jQuery or Dojo) and I prefer not to insert tons of libraries now, only for once, for a trivial use.
Is there a plan javascript solution more elegant and universal and exportable instead ofsubstitute the braces at the origin with another character and replace this at destination before parsing?

m. mann
  • 31
  • 5

1 Answers1

1

The { symbol should be replaced with %7B and } with %7D.

The easiest way would be to do something like:

window.encodeURIComponent(JSON.stringify({
    "datavz":"09/04/2018 14:18:12",
    "descavz":"foo foo",
    "idprat":32,
    "codprat":"123456",
    "costs":[]
}));

// %7B%22datavz%22%3A%2209%2F04%2F2018%2014%3A18%3A12%22%2C%22descavz%22%3A%22foo%20foo%22%2C%22idprat%22%3A32%2C%22codprat%22%3A%22123456%22%2C%22costs%22%3A%5B%5D%7D

You shouldn't need to replace this at destination before parsing, since that should be done automatically as it is URL encoded, and it coming from the URL.

dave
  • 62,300
  • 5
  • 72
  • 93
  • thanx Dave, I'm going to try. Someone knows why this change of policy? There's a real improvement in Tomcat performance? and, in Tomcat 8.5 and 9, there,s the same policy? – m. mann Apr 10 '18 at 08:32