cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Neal Hu (JIRA)" <>
Subject [jira] [Commented] (CXF-7071) HttpServletRequest.getParameter only get String from query not both posted form data
Date Tue, 04 Oct 2016 08:03:20 GMT


Neal Hu commented on CXF-7071:

The root cause is that the ways parsing the parameter from the input stream are different
between WebContainer and CXF. If we get parameter in ServletFilter first, so the injected
request will get the data from the cache(WebContainer consumed input stream). If we get the
parameter directly, the injected request will get the data by CXF. The behavior is obviously

The property you mentioned will invoke req.getParameterNames() and pre read the data via WebContainer
and cache the data. It is an only work around, the root cause may here:

List<Object> params = JAXRSUtils.processParameters(ori, matchedValues, message);->org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(Class<?>,
Type, Annotation[], Parameter, MultivaluedMap<String, String>, Message, OperationResourceInfo)

We may need put the data parsed from body into request.getParameterMap()

> HttpServletRequest.getParameter only get String from query not both posted form data
> ------------------------------------------------------------------------------------
>                 Key: CXF-7071
>                 URL:
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.1.7
>            Reporter: Neal Hu
>             Fix For: 3.1.8
> The http request:
>  POST /dubbott-demo-provider/v1.0/users/beanparam HTTP/1.1
> HOST: localhost:8080
> accept: text/plain
> content-type: application/x-www-form-urlencoded
> content-length: 12
> pageIndex=99
> The resource method returns null:
> {code:java}
>     public String beanParam(@Context HttpServletRequest req, String ak) {
>         String pageIndex = req.getParameter("pageIndex")    
>         return pageIndex;
>     }
> {code}
> From the servlet 3.1 API doc:
> String javax.servlet.ServletRequest.getParameter(String name)
> Returns the value of a request parameter as a String, or null if the parameter does not
exist. Request parameters are extra information sent with the request. For HTTP servlets,
parameters are contained in the query string or posted form data.
> if we add below servlet filter:
> {code:java}
> 	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
> 	        System.out.println(request.getParameter("pageIndex") );
> 		chain.doFilter(request, response);
> 	}
> {code}
> The output is "99" the response is the same "99".
> As a conclusion the CXF HttpServletRequest doesn't comply the Servlet 3.1 API Spec.

This message was sent by Atlassian JIRA

View raw message