You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "John Tran (JIRA)" <ji...@apache.org> on 2010/09/14 21:09:38 UTC
[jira] Created: (CXF-2993) @Context HttpServletRequest does not
contain POST data. It's however is in MultivaluedMap .
@Context HttpServletRequest does not contain POST data. It's however is in MultivaluedMap<String, String> .
------------------------------------------------------------------------------------------------------------
Key: CXF-2993
URL: https://issues.apache.org/jira/browse/CXF-2993
Project: CXF
Issue Type: Bug
Components: JAX-RS
Affects Versions: 2.2.10, 2.2.9
Environment: Dev
Reporter: John Tran
I try to use @Context HttpServletRequest from my JAX-RS method to retrieve POST data but it's not there. It's however is in MultivaluedMap<String, String> parameterMap
Here is the code.
@Resource
@Path("/rating")
public class RatingRs {
@Path("/create")
@POST
@Consumes("application/x-www-form-urlencoded")
@Produces("application/json")
public void createRating( @Context HttpServletRequest requestObject, @Context HttpServletResponse response, MultivaluedMap<String, String> parameterMap){
Map map = requestObject.getParameterMap(); //THIS RETURNS EMPTY, WHY? SHOULD CONTAIN "itemId"="blah"
String itemId = requestObject.getParameter("itemId"); //returns null SHOULD NOT BE NULL
List values = parameterMap.get("itemId"); //RETURNS THE CORRECT VALUE HERE.
}
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CXF-2993) @Context HttpServletRequest does not
contain POST data. It's however is in MultivaluedMap .
Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-2993?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12913266#action_12913266 ]
Sergey Beryozkin commented on CXF-2993:
---------------------------------------
Hi - please see systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoInterface.java on the trunk with a test confirming that parameters can be retrieved from HttpServletContext if no MultivaluedMap is provided.
Can you please recheck once again that
public Response createRating( @Context HttpServletRequest requestObject, @Context HttpServletResponse response){
System.out.println(requestObject.getParameterMap()); //This print out an empty map {}, IT SHOULD BE {"itemId":"blah"}
}
}
does not give the populated map ?
CXF will get the parameters if MultivaluedMap or @Form parameters are used in case InputStream is empty - this is per the JAXRS 1.1 requirements. But it definitely should not consume them if only HttpServletRequest is provided...
can you recheck please and may be even debug if the problem persists ?
> @Context HttpServletRequest does not contain POST data. It's however is in MultivaluedMap<String, String> .
> ------------------------------------------------------------------------------------------------------------
>
> Key: CXF-2993
> URL: https://issues.apache.org/jira/browse/CXF-2993
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.2.9, 2.2.10
> Environment: Dev
> Reporter: John Tran
>
> I try to use @Context HttpServletRequest from my JAX-RS method to retrieve POST data but it's not there. It's however is in MultivaluedMap<String, String> parameterMap
> Here is the code.
> @Resource
> @Path("/rating")
> public class RatingRs {
> @Path("/create")
> @POST
> @Consumes("application/x-www-form-urlencoded")
> @Produces("application/json")
> public void createRating( @Context HttpServletRequest requestObject, @Context HttpServletResponse response, MultivaluedMap<String, String> parameterMap){
>
> Map map = requestObject.getParameterMap(); //THIS RETURNS EMPTY, WHY? SHOULD CONTAIN "itemId"="blah"
> String itemId = requestObject.getParameter("itemId"); //returns null SHOULD NOT BE NULL
> List values = parameterMap.get("itemId"); //RETURNS THE CORRECT VALUE HERE.
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (CXF-2993) @Context HttpServletRequest does not
contain POST data. It's however is in MultivaluedMap .
Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-2993?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sergey Beryozkin resolved CXF-2993.
-----------------------------------
Resolution: Invalid
I'm closing it as won't fix - please feel free to reopen if you could confirm that having only HttpServletRequest still consumes the post data - I have the test which I believe proves it should work as expected
> @Context HttpServletRequest does not contain POST data. It's however is in MultivaluedMap<String, String> .
> ------------------------------------------------------------------------------------------------------------
>
> Key: CXF-2993
> URL: https://issues.apache.org/jira/browse/CXF-2993
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.2.9, 2.2.10
> Environment: Dev
> Reporter: John Tran
>
> I try to use @Context HttpServletRequest from my JAX-RS method to retrieve POST data but it's not there. It's however is in MultivaluedMap<String, String> parameterMap
> Here is the code.
> @Resource
> @Path("/rating")
> public class RatingRs {
> @Path("/create")
> @POST
> @Consumes("application/x-www-form-urlencoded")
> @Produces("application/json")
> public void createRating( @Context HttpServletRequest requestObject, @Context HttpServletResponse response, MultivaluedMap<String, String> parameterMap){
>
> Map map = requestObject.getParameterMap(); //THIS RETURNS EMPTY, WHY? SHOULD CONTAIN "itemId"="blah"
> String itemId = requestObject.getParameter("itemId"); //returns null SHOULD NOT BE NULL
> List values = parameterMap.get("itemId"); //RETURNS THE CORRECT VALUE HERE.
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CXF-2993) @Context HttpServletRequest does not
contain POST data. It's however is in MultivaluedMap .
Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-2993?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12909707#action_12909707 ]
Sergey Beryozkin commented on CXF-2993:
---------------------------------------
This is because MultivaluedMap consumes the POST data as per the JAXRS spec. If you prefer to read it from the requestObject manually then just drop the MultivaluedMap from the signature
> @Context HttpServletRequest does not contain POST data. It's however is in MultivaluedMap<String, String> .
> ------------------------------------------------------------------------------------------------------------
>
> Key: CXF-2993
> URL: https://issues.apache.org/jira/browse/CXF-2993
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.2.9, 2.2.10
> Environment: Dev
> Reporter: John Tran
>
> I try to use @Context HttpServletRequest from my JAX-RS method to retrieve POST data but it's not there. It's however is in MultivaluedMap<String, String> parameterMap
> Here is the code.
> @Resource
> @Path("/rating")
> public class RatingRs {
> @Path("/create")
> @POST
> @Consumes("application/x-www-form-urlencoded")
> @Produces("application/json")
> public void createRating( @Context HttpServletRequest requestObject, @Context HttpServletResponse response, MultivaluedMap<String, String> parameterMap){
>
> Map map = requestObject.getParameterMap(); //THIS RETURNS EMPTY, WHY? SHOULD CONTAIN "itemId"="blah"
> String itemId = requestObject.getParameter("itemId"); //returns null SHOULD NOT BE NULL
> List values = parameterMap.get("itemId"); //RETURNS THE CORRECT VALUE HERE.
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CXF-2993) @Context HttpServletRequest does not
contain POST data. It's however is in MultivaluedMap .
Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-2993?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12910049#action_12910049 ]
Sergey Beryozkin commented on CXF-2993:
---------------------------------------
I see...
HttpServletContext wrapper just delegates to the underlying HttpServletContext object provided by the container.
Whatever its getParameterMap() returns will be returned by the @Context instance.
JAXRS runtime does not interfere in that process at all.
If you get an InputStream from the request object and parse the stream then you'll get the values, this is how
MultivaluedMap is being populated by the form provider...
Can you try adding a test filter and confirm getParameterMap() returns a populated map, before the request reaches CXF servlet ?
> @Context HttpServletRequest does not contain POST data. It's however is in MultivaluedMap<String, String> .
> ------------------------------------------------------------------------------------------------------------
>
> Key: CXF-2993
> URL: https://issues.apache.org/jira/browse/CXF-2993
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.2.9, 2.2.10
> Environment: Dev
> Reporter: John Tran
>
> I try to use @Context HttpServletRequest from my JAX-RS method to retrieve POST data but it's not there. It's however is in MultivaluedMap<String, String> parameterMap
> Here is the code.
> @Resource
> @Path("/rating")
> public class RatingRs {
> @Path("/create")
> @POST
> @Consumes("application/x-www-form-urlencoded")
> @Produces("application/json")
> public void createRating( @Context HttpServletRequest requestObject, @Context HttpServletResponse response, MultivaluedMap<String, String> parameterMap){
>
> Map map = requestObject.getParameterMap(); //THIS RETURNS EMPTY, WHY? SHOULD CONTAIN "itemId"="blah"
> String itemId = requestObject.getParameter("itemId"); //returns null SHOULD NOT BE NULL
> List values = parameterMap.get("itemId"); //RETURNS THE CORRECT VALUE HERE.
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CXF-2993) @Context HttpServletRequest does not
contain POST data. It's however is in MultivaluedMap .
Posted by "John Tran (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-2993?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12909961#action_12909961 ]
John Tran commented on CXF-2993:
--------------------------------
I dropped the MultivaluedMap from the signature, but NO LUCK.
Here is the code.
@Resource
@Path("/rating")
public class RatingRs {
@Path("/create")
@POST
@Consumes("application/x-www-form-urlencoded")
@Produces("application/json")
public Response createRating( @Context HttpServletRequest requestObject, @Context HttpServletResponse response){
System.out.println(requestObject.getParameterMap()); //This print out an empty map {}, IT SHOULD BE {"itemId":"blah"}
}
}
> @Context HttpServletRequest does not contain POST data. It's however is in MultivaluedMap<String, String> .
> ------------------------------------------------------------------------------------------------------------
>
> Key: CXF-2993
> URL: https://issues.apache.org/jira/browse/CXF-2993
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.2.9, 2.2.10
> Environment: Dev
> Reporter: John Tran
>
> I try to use @Context HttpServletRequest from my JAX-RS method to retrieve POST data but it's not there. It's however is in MultivaluedMap<String, String> parameterMap
> Here is the code.
> @Resource
> @Path("/rating")
> public class RatingRs {
> @Path("/create")
> @POST
> @Consumes("application/x-www-form-urlencoded")
> @Produces("application/json")
> public void createRating( @Context HttpServletRequest requestObject, @Context HttpServletResponse response, MultivaluedMap<String, String> parameterMap){
>
> Map map = requestObject.getParameterMap(); //THIS RETURNS EMPTY, WHY? SHOULD CONTAIN "itemId"="blah"
> String itemId = requestObject.getParameter("itemId"); //returns null SHOULD NOT BE NULL
> List values = parameterMap.get("itemId"); //RETURNS THE CORRECT VALUE HERE.
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CXF-2993) @Context HttpServletRequest does not
contain POST data. It's however is in MultivaluedMap .
Posted by "John Tran (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-2993?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12912246#action_12912246 ]
John Tran commented on CXF-2993:
--------------------------------
Thanks Sergey, I put in a filter and it works. I'm just wondering why CXF decides to take away the form data from HttpServletRequest.getParameterMap or getParameter. Is it part of JAX-RS spec?
> @Context HttpServletRequest does not contain POST data. It's however is in MultivaluedMap<String, String> .
> ------------------------------------------------------------------------------------------------------------
>
> Key: CXF-2993
> URL: https://issues.apache.org/jira/browse/CXF-2993
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.2.9, 2.2.10
> Environment: Dev
> Reporter: John Tran
>
> I try to use @Context HttpServletRequest from my JAX-RS method to retrieve POST data but it's not there. It's however is in MultivaluedMap<String, String> parameterMap
> Here is the code.
> @Resource
> @Path("/rating")
> public class RatingRs {
> @Path("/create")
> @POST
> @Consumes("application/x-www-form-urlencoded")
> @Produces("application/json")
> public void createRating( @Context HttpServletRequest requestObject, @Context HttpServletResponse response, MultivaluedMap<String, String> parameterMap){
>
> Map map = requestObject.getParameterMap(); //THIS RETURNS EMPTY, WHY? SHOULD CONTAIN "itemId"="blah"
> String itemId = requestObject.getParameter("itemId"); //returns null SHOULD NOT BE NULL
> List values = parameterMap.get("itemId"); //RETURNS THE CORRECT VALUE HERE.
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.