Reputation: 357
I have some strange question: When we submit html form via POST all our params go to request body, if it's GET submit: params go to queryString in URL.
But we can't be stoped for example we can send POST with params in body and queryString in URL. Here is the issue, tomcat parse request and make org.apache.coyote.Request object - all params from queryString and body go to ParameterMap and I can't detect where from parameters come. I can get queryString and parse params from it, but i can't detect was this param in body or not.
Examples:
1)
<form method="POST" action="someUrl/?a=1&a=2">
<input type="hidden" name="a" value="1"/>
<input type="hidden" name="a" value="2"/>
...
</form>
parameter map will have two values 1,2 without any information where they come from.
2)
<form method="POST" action="someUrl/?a=1&a=2">
...
</form>
parameter map will also have two values 1,2 without any information was they in the body or not.
Should i rewrite tomcat's request parsing logic, wrap request and etc? If should - i think i need a manual. Any ideas, guesses. Thank you.
Upvotes: 0
Views: 843
Reputation: 149075
Tomcat expects that parameters can come from either the query string or the request body, so it merges it for you not to have to search in both.
But if you really want to allow non standard usage of parameters, you can get the query string (and parse it to find request string parameters) with request.getQueryString()
.
And you can separately read the request body with request.getReader()
, and then parse it to find in body parameters.
Usage of the ParameterMap is a help for standard uses, but nothing forces you to actually use it.
Upvotes: 1