|ServletBridge returns multiple values for empty url parameters (?param=) [message #1835909]
||Wed, 16 December 2020 10:18
| Linuxhippy Mising name
Registered: July 2009
While hunting down an application-bug, I found the equinox servlet bridge has rather weird behaviour when it comes to empty parameters, that differ from what "normal" servlet engines seem to do.
In case of an empty parameter (?param=), getParameter("param") returns null instead of an empty string. This is the result of getParameterValues("param") actually returns a two-entry array [null, ""] and getParameter simply returns the first parameter of that array.
The reason is:
- DispatchTarget.queryStringToParameterMap() does not handle the empty parameter and inserts null as value in the map
- later, DispatchTarget.getParameterMap() checks the parameters just parsed equal the parameters returned by currentRequest.getParameterMap() - and finds that they are not equal.
The "real" servlet-engine parsed "" for the empty parameter, so that value is added to the array.
To me, as someone looking at this code without in-depth knowledge, the code seems a bit unclear (the whole file contains two one-liner comments btw.):
- Why are query parameters parsed by the servlet bridge itself not delegated to the parent servlet engine?
- Why are later the parameters parsed by the servlet engine compared to the self-parsed parameters? Wouldn't it be sufficient to simply copy the map provided by the servlet-engine (currentRequest.getParameterMap())?
Thanks & best Regards, Clemens
Powered by FUDForum
. Page generated in 0.01512 seconds